package com.boot.web.serviceImpl;

import com.boot.utils.Units;
import com.boot.web.dao.*;
import com.boot.web.entity.*;
import com.boot.web.service.CustomerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.boot.web.service.OrdersShareRepeatService;
import com.boot.base.serviceImpl.BaseServiceImpl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 共享订单复消业务层接口实现
 * @author 【zhouJie】
 * @date 2021-11-08 11:29:22
 */
@Service
public class OrdersShareRepeatServiceImpl extends BaseServiceImpl<OrdersShareRepeat> implements OrdersShareRepeatService {

    private static final Logger logger = LoggerFactory.getLogger(OrdersShareRepeatServiceImpl.class);

    @Autowired
    private OrdersShareRepeatDao ordersShareRepeatDao;

    @Autowired
    private OrdersDao ordersDao;

    @Autowired
    private OrderDetailsDao orderDetailsDao;

    @Autowired
    private SpecAttributeDao specAttributeDao;

    @Autowired
    private SkuRelationDao skuRelationDao;

    @Autowired
    private ProductDao productDao;

    @Autowired
    private AccountDao accountDao;

    @Autowired
    private AccountRecordDao accountRecordDao;

    @Autowired
    private StoreShopDao storeShopDao;

    @Autowired
    private ClassifyDao classifyDao;

    @Autowired
    private CustomerDao customerDao;

    @Autowired
    private PrizePoolWeeklyDao prizePoolWeeklyDao;

    @Autowired
    private PrizePoolDao prizePoolDao;

    @Autowired
    private GoodsOrdersDao goodsOrdersDao;

    @Autowired
    private CustomerService customerService;

    @Autowired
    private PrizePoolLoveDao prizePoolLoveDao;

    @Autowired
    private PrizePoolAreanDao prizePoolAreanDao;


    @Override
    public boolean handleCreateAndRepeatShareOrders(Integer userId) {
        boolean temp = false;
        String outTradeNo = "BEE" + Units.getOrderIdByTime().replaceAll("-", "");
        String tradeNo = "JYH" + Units.getOrderIdByTime().replaceAll("-", "");
        // 默认复消369礼包中的第一个产品
        //List<Product> productList = productDao.queryProductByClassifyId(10);
        Customer customer = customerDao.queryById(userId);
        //if(productList.size() > 0 && customer != null){
        if(customer != null){
            //Product product = productList.get(0);
            Product product = productDao.queryById(603); // 复消产品
            List<SkuRelation> skuList = skuRelationDao.queryByProductId(product.getId());
            //默认取sku第一个
            SkuRelation sku = skuList.get(0);
            BigDecimal bd369 = new BigDecimal(369);
            BigDecimal bd0 = new BigDecimal(0);
            Date date = new Date();
            // 创建订单
            Orders newO = new Orders();
            newO.setOrderNo(outTradeNo);
            newO.setTradeNo(tradeNo);
            newO.setTotalAmount(bd369);
            newO.setPayAmount(bd369);
            newO.setCouponAmount(bd0);
            newO.setFreight(bd0);
            newO.setPayStatus("1"); // 支付成功
            newO.setPayType("6"); // 共享余额支付(走冻结)
            newO.setDealStatus("3"); //交易完成
            newO.setRefundStatus("0");
            newO.setOrderPersonId(userId);
            newO.setUpdateTime(date);
            newO.setIsDel("0");
            newO.setRemarks("复消订单");
            newO.setProductId(product.getId());
            ordersDao.save(newO);
            // 创建订单详情
            OrderDetails od = new OrderDetails();
            od.setOrderNo(newO.getOrderNo());
            od.setTradeNo(newO.getTradeNo());
            od.setStoreShopId(product.getStoreShopId());
            od.setStoreShopName(storeShopDao.queryById(product.getStoreShopId()).getName());
            od.setClassifyId(product.getClassifyId());
            od.setClassifyName(classifyDao.queryById(product.getClassifyId()).getName());
            od.setProductId(product.getId());
            od.setProductType(product.getType());
            od.setProductImg(product.getImg());
            od.setProductName(product.getName());
            od.setProductCode(product.getProductCode());
            od.setCostPrice(sku.getCostPrice());
            od.setRelationId(sku.getId());
            if(sku.getGroupRelation().contains(",")){
                String[] strings = sku.getGroupRelation().split(",");
                String str = "";
                for(int u = 0; u < strings.length; u++){
                    str += specAttributeDao.queryById(Integer.parseInt(strings[u])).getAttributeName() + "，";
                }
                od.setSpecAttributeName(str.substring(0, str.length()-1));
            }else{
                od.setSpecAttributeName(specAttributeDao.queryById(Integer.parseInt(sku.getGroupRelation())).getAttributeName());
            }
            od.setQuantity(1);
            od.setUnitPrice(sku.getRetailPrice());
            od.setUpdateTime(date);
            orderDetailsDao.save(od);
            // 修改账户
            Account account = accountDao.queryAccountByUserId(userId);
            account.setFrozenIn(account.getFrozenIn().subtract(bd369));
            accountDao.update(account);
            // 添加账户明细记录
            AccountRecord ar = new AccountRecord();
            ar.setOutUserId(userId);
            ar.setUpdateTime(date);
            ar.setType("10");
            ar.setAmount(bd369);
            ar.setNowAmount(account.getFrozenIn());
            ar.setSign("2");
            ar.setOrderNo(outTradeNo);
            ar.setInfo("冻结余额已满足复消，消耗：" + bd369);
            accountRecordDao.save(ar);
            // 添加销量
            product.setSales(product.getSales() + 1);
            productDao.update(product);
            // 加复消业绩累计
            customer.setRepeatAmount(customer.getRepeatAmount().add(BigDecimal.valueOf(369)));
            customerDao.update(customer);
            // 周奖金池，总奖金池，红包券，擂台奖池，爱心奖池
            sharingMode(newO);

            // 添加业绩
            //addAchievementAndOrderQuantity(newO);

            // 升级
            //shareUpgrade(customer, newO.getTotalAmount());

            // 分润
            shareSplitProfit(customer, newO);
            temp = true;
        }
        return temp;
    }


    /**
     * 共享模式 处理用户购买后的奖金池，红包券，分润
     * @param orders
     */
    public void sharingMode(Orders orders){
        try {
            // 下单人
            Customer customer = customerDao.queryById(orders.getOrderPersonId());

            // 上级信息
            Customer parentCustomer = null;
            Account parentAccount = null;
            if(customer.getParentId() != null && customer.getParentId() != 1198){
                parentCustomer = customerDao.queryById(customer.getParentId());
                parentAccount = accountDao.queryAccountByUserId(parentCustomer.getId());
            }

            // 系统当前时间
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date toDate = new Date();
            Calendar now = Calendar.getInstance();
            now.setTime(toDate);
            String date = sdf.format(now.getTime());
            now.add(Calendar.DAY_OF_MONTH, -1);
            String date1 = sdf.format(now.getTime());
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            // 获取周奖金池
            BigDecimal weeklyAmount = orders.getPayAmount().multiply(BigDecimal.valueOf(0.4)); // 40%
            PrizePoolWeekly ppw = prizePoolWeeklyDao.queryByBeginTimeAndEndTime(format1.format(toDate));
            if(ppw == null){
                PrizePoolWeekly newW = new PrizePoolWeekly();
                newW.setBeginTime(toDate);
                newW.setPayMoney(weeklyAmount);

                int num = 6; // 加的天数
                String endTime = format1.format(toDate);
                Date currDate = format1.parse(endTime);
                Calendar ca = Calendar.getInstance();
                ca.setTime(currDate);
                ca.add(Calendar.DATE, num);
                currDate = ca.getTime();
                newW.setEndTime(currDate);
                newW.setSplitMoney(new BigDecimal(0));
                prizePoolWeeklyDao.save(newW);
            }else{
                ppw.setPayMoney(ppw.getPayMoney().add(weeklyAmount));
                prizePoolWeeklyDao.update(ppw);
            }

            // 获取今日奖金池
            PrizePool prizePool = prizePoolDao.queryByToday(date);
            if(prizePool == null){
                prizePool = prizePoolDao.queryByToday(date1); // TODO 每天凌晨0点-2点的共享订单，统计到昨天计算，2点后的统计到今日计算
            }
            prizePool.setTotalMoney(prizePool.getTotalMoney().add(orders.getTotalAmount())); // 加奖池 -产品金额
            prizePool.setPayMoney(prizePool.getPayMoney().add(orders.getPayAmount())); // 支付金额

            // 一共的金额
            BigDecimal sumAmount = orders.getTotalAmount().add(customer.getOwnTotalBuy3());
            customer.setOwnTotalBuy3(sumAmount);
            customerDao.update(customer);

            // 分红包券
            if(orders.getTotalAmount().doubleValue() >= 369 && orders.getTotalAmount().doubleValue() < 3690){
                prizePool.setRedPackQuantity(prizePool.getRedPackQuantity() + 1); // 加奖金池红包券
                parentAccount.setRedPacket(parentAccount.getRedPacket() + 1);// 加上级个人红包券
            }else if(orders.getTotalAmount().doubleValue() >= 3690 && orders.getTotalAmount().doubleValue() < 36900){
                prizePool.setRedPackQuantity(prizePool.getRedPackQuantity() + 10); // 加奖金池红包券
                parentAccount.setRedPacket(parentAccount.getRedPacket() + 10);// 加上级个人红包券
            }else if(orders.getTotalAmount().doubleValue() >= 36900){
                prizePool.setRedPackQuantity(prizePool.getRedPackQuantity() + 100); // 加奖金池红包券
                parentAccount.setRedPacket(parentAccount.getRedPacket() + 100);// 加上级个人红包券
            }
            accountDao.update(parentAccount);
            prizePoolDao.update(prizePool);

            // 爱心奖金池 1%
            PrizePoolLove love = prizePoolLoveDao.queryByToday(date); // 每日
            if(love == null){
                // 创建今日
                PrizePoolLove newLove = new PrizePoolLove();
                newLove.setUpdateTime(new Date());
                newLove.setSplitMoney(new BigDecimal(0));
                newLove.setPayMoney(orders.getTotalAmount().multiply(BigDecimal.valueOf(0.01)));
                prizePoolLoveDao.save(newLove);
            }else{
                // 今日继续累加
                love.setPayMoney(love.getPayMoney().add(orders.getTotalAmount().multiply(BigDecimal.valueOf(0.01))));
                prizePoolLoveDao.update(love);
            }

            // 擂台奖金池 4%
            PrizePoolArean arean = prizePoolAreanDao.queryByToday(date); // 每日
            if(arean == null){
                // 创建今日
                PrizePoolArean newArean = new PrizePoolArean();
                newArean.setUpdateTime(new Date());
                newArean.setSplitMoney(new BigDecimal(0));
                newArean.setPayMoney(orders.getTotalAmount().multiply(BigDecimal.valueOf(0.04)));
                prizePoolAreanDao.save(newArean);
            }else{
                // 今日继续累加
                arean.setPayMoney(arean.getPayMoney().add(orders.getTotalAmount().multiply(BigDecimal.valueOf(0.04))));
                prizePoolAreanDao.update(arean);
            }

        }catch (Exception e){
            e.printStackTrace();

        }finally {

        }
    }


    /**
     * 共享模式 处理用户购买后的升级
     * @param customer
     * @param totalAmount
     */
    public void shareUpgrade(Customer customer, BigDecimal totalAmount){
        if(totalAmount.doubleValue() >= 369 && totalAmount.doubleValue() < 3690){
            if(customer.getLevelCopy3Id() < 2){
                customer.setLevelCopy3Id(2);
                if("0".equals(customer.getIsActiveCopy3())){
                    customer.setIsActiveCopy3("1"); // 激活共享另一套等级
                }
                customerDao.update(customer);
            }
        }else if(totalAmount.doubleValue() >= 3690 && totalAmount.doubleValue() < 36900){
            if(customer.getLevelCopy3Id() < 3){
                customer.setLevelCopy3Id(3);
                if("0".equals(customer.getIsActiveCopy3())){
                    customer.setIsActiveCopy3("1"); // 激活共享另一套等级
                }
                customerDao.update(customer);
            }
        }else if(totalAmount.doubleValue() >= 36900){
            if(customer.getLevelCopy3Id() < 4){
                customer.setLevelCopy3Id(4);
                if("0".equals(customer.getIsActiveCopy3())){
                    customer.setIsActiveCopy3("1"); // 激活共享另一套等级
                }
                customerDao.update(customer);
            }
        }

        // 处理共享另一套等级
        if(customer.getParentId() != null && customer.getParentId() != 1198 && customer.getLevelCopy4Id() != 8){
            Customer cu1 = customerDao.queryById(customer.getParentId());
            if(cu1 != null){
                if(cu1.getLevelCopy4Id() == 1){ // v0
                    // 判断是否升V1
                    // 查询下级是否有两条线满足50单
                    int rowSize1 = customerDao.queryByOrderQuantity50(cu1.getId());
                    if(rowSize1 >= 2){
                        cu1.setLevelCopy4Id(2);
                        customerDao.update(cu1);

                        if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                            Customer cu2 = customerDao.queryById(cu1.getParentId());
                            if(cu2 != null){
                                // 判断王者是否升V2
                                // 查询下级是否有500单同时拥有3个V1
                                int total2 = customerDao.queryByOrderQuantityTotal(cu2.getId());
                                int rowSize2 = customerDao.queryByLevelV2(2, cu2.getId());
                                if(total2 >= 500){
                                    if(rowSize2 >= 3){
                                        cu2.setLevelCopy4Id(3);
                                        customerDao.update(cu2);

                                        if(cu2.getParentId() != null && cu2.getParentId() != 1198 && cu2.getLevelCopy4Id() != 8){
                                            Customer cu3 = customerDao.queryById(cu2.getParentId());
                                            if(cu3 != null){
                                                // 判断王者是否升V3
                                                // 查询下级是否有3000单同时拥有3个V2
                                                int total3 = customerDao.queryByOrderQuantityTotal(cu3.getId());
                                                int rowSize3 = customerDao.queryByLevelV3(3, cu3.getId());
                                                if(total3 >= 3000){
                                                    if(rowSize3 >= 3){
                                                        cu3.setLevelCopy4Id(4);
                                                        customerDao.update(cu3);

                                                        if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                            Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                            if (cu4 != null) {
                                                                // 判断王者是否升V4
                                                                // 查询下级是否有9000单同时拥有3个V3
                                                                int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                if(total4 >= 9000){
                                                                    if(rowSize4 >= 3){
                                                                        cu4.setLevelCopy4Id(5);
                                                                        customerDao.update(cu4);

                                                                        if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                            Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                            if(cu5 != null) {
                                                                                // 判断王者是否升V5
                                                                                // 查询下级是否有27000单同时拥有3个V4
                                                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                if(total5 >= 27000){
                                                                                    if(rowSize5 >= 3){
                                                                                        cu5.setLevelCopy4Id(6);
                                                                                        customerDao.update(cu5);

                                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                            if(cu6 != null) {
                                                                                                // 判断王者是否升V6
                                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                if(total6 >= 81000){
                                                                                                    if(rowSize6 >= 3){
                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                        customerDao.update(cu6);

                                                                                                    }else {
                                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                        if (queryList6.size() > 0) {
                                                                                                            int index6 = rowSize6;
                                                                                                            for (Customer c6 : queryList6) {
                                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                if (temp6 > 0) {
                                                                                                                    c6.setLevelV5("1");
                                                                                                                    customerDao.update(c6);
                                                                                                                }
                                                                                                                index6 += temp6;
                                                                                                                if (index6 >= 3) {
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);
                                                                                                                    break;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }

                                                                                    }else {
                                                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                        if (queryList5.size() > 0) {
                                                                                            int index5 = rowSize5;
                                                                                            for (Customer c5 : queryList5) {
                                                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                if (temp5 > 0) {
                                                                                                    c5.setLevelV4("1");
                                                                                                    customerDao.update(c5);
                                                                                                }
                                                                                                index5 += temp5;
                                                                                                if (index5 >= 3) {
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                    }else {
                                                                        List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                        if (queryList4.size() > 0) {
                                                                            int index4 = rowSize4;
                                                                            for (Customer c4 : queryList4) {
                                                                                int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                if (temp4 > 0) {
                                                                                    c4.setLevelV3("1");
                                                                                    customerDao.update(c4);
                                                                                }
                                                                                index4 += temp4;
                                                                                if (index4 >= 3) {
                                                                                    cu4.setLevelCopy4Id(5);
                                                                                    customerDao.update(cu4);

                                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                        if(cu5 != null) {
                                                                                            // 判断王者是否升V5
                                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                            if(total5 >= 27000){
                                                                                                if(rowSize5 >= 3){
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }

                                                                                                }else {
                                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                    if (queryList5.size() > 0) {
                                                                                                        int index5 = rowSize5;
                                                                                                        for (Customer c5 : queryList5) {
                                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                            if (temp5 > 0) {
                                                                                                                c5.setLevelV4("1");
                                                                                                                customerDao.update(c5);
                                                                                                            }
                                                                                                            index5 += temp5;
                                                                                                            if (index5 >= 3) {
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                    }else {
                                                        List<Customer> queryList3 = customerDao.queryCustomerByLevelCopy4Id(3, cu3.getId());
                                                        if (queryList3.size() > 0) {
                                                            int index3 = rowSize3;
                                                            for (Customer c3 : queryList3) {
                                                                int temp3 = customerService.recursionCustomer_4(3, c3.getId());
                                                                if (temp3 > 0) {
                                                                    c3.setLevelV2("1");
                                                                    customerDao.update(c3);
                                                                }
                                                                index3 += temp3;
                                                                if (index3 >= 3) {
                                                                    cu3.setLevelCopy4Id(4);
                                                                    customerDao.update(cu3);

                                                                    if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                                        Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                                        if (cu4 != null) {
                                                                            // 判断王者是否升V4
                                                                            // 查询下级是否有9000单同时拥有3个V3
                                                                            int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                            int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                            if(total4 >= 9000){
                                                                                if(rowSize4 >= 3){
                                                                                    cu4.setLevelCopy4Id(5);
                                                                                    customerDao.update(cu4);

                                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                        if(cu5 != null) {
                                                                                            // 判断王者是否升V5
                                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                            if(total5 >= 27000){
                                                                                                if(rowSize5 >= 3){
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }

                                                                                                }else {
                                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                    if (queryList5.size() > 0) {
                                                                                                        int index5 = rowSize5;
                                                                                                        for (Customer c5 : queryList5) {
                                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                            if (temp5 > 0) {
                                                                                                                c5.setLevelV4("1");
                                                                                                                customerDao.update(c5);
                                                                                                            }
                                                                                                            index5 += temp5;
                                                                                                            if (index5 >= 3) {
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }

                                                                                }else {
                                                                                    List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                                    if (queryList4.size() > 0) {
                                                                                        int index4 = rowSize4;
                                                                                        for (Customer c4 : queryList4) {
                                                                                            int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                            if (temp4 > 0) {
                                                                                                c4.setLevelV3("1");
                                                                                                customerDao.update(c4);
                                                                                            }
                                                                                            index4 += temp4;
                                                                                            if (index4 >= 3) {
                                                                                                cu4.setLevelCopy4Id(5);
                                                                                                customerDao.update(cu4);

                                                                                                if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                                    Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                                    if(cu5 != null) {
                                                                                                        // 判断王者是否升V5
                                                                                                        // 查询下级是否有27000单同时拥有3个V4
                                                                                                        int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                                        int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                                        if(total5 >= 27000){
                                                                                                            if(rowSize5 >= 3){
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                            }else {
                                                                                                                List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                                if (queryList5.size() > 0) {
                                                                                                                    int index5 = rowSize5;
                                                                                                                    for (Customer c5 : queryList5) {
                                                                                                                        int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                                        if (temp5 > 0) {
                                                                                                                            c5.setLevelV4("1");
                                                                                                                            customerDao.update(c5);
                                                                                                                        }
                                                                                                                        index5 += temp5;
                                                                                                                        if (index5 >= 3) {
                                                                                                                            cu5.setLevelCopy4Id(6);
                                                                                                                            customerDao.update(cu5);

                                                                                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                                if(cu6 != null) {
                                                                                                                                    // 判断王者是否升V6
                                                                                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                                    if(total6 >= 81000){
                                                                                                                                        if(rowSize6 >= 3){
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);

                                                                                                                                        }else {
                                                                                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                            if (queryList6.size() > 0) {
                                                                                                                                                int index6 = rowSize6;
                                                                                                                                                for (Customer c6 : queryList6) {
                                                                                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                                    if (temp6 > 0) {
                                                                                                                                                        c6.setLevelV5("1");
                                                                                                                                                        customerDao.update(c6);
                                                                                                                                                    }
                                                                                                                                                    index6 += temp6;
                                                                                                                                                    if (index6 >= 3) {
                                                                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                                                                        customerDao.update(cu6);
                                                                                                                                                        break;
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                            break;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                break;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                    }else {
                                        List<Customer> queryList2 = customerDao.queryCustomerByLevelCopy4Id(2, cu2.getId());
                                        if (queryList2.size() > 0) {
                                            int index2 = rowSize2;
                                            for (Customer c2 : queryList2) {
                                                int temp2 = customerService.recursionCustomer_4(2, c2.getId());
                                                if (temp2 > 0) {
                                                    c2.setLevelV1("1");
                                                    customerDao.update(c2);
                                                }
                                                index2 += temp2;
                                                if (index2 >= 3) {
                                                    cu2.setLevelCopy4Id(3);
                                                    customerDao.update(cu2);

                                                    if(cu2.getParentId() != null && cu2.getParentId() != 1198 && cu2.getLevelCopy4Id() != 8){
                                                        Customer cu3 = customerDao.queryById(cu2.getParentId());
                                                        if(cu3 != null){
                                                            // 判断王者是否升V3
                                                            // 查询下级是否有3000单同时拥有3个V2
                                                            int total3 = customerDao.queryByOrderQuantityTotal(cu3.getId());
                                                            int rowSize3 = customerDao.queryByLevelV3(3, cu3.getId());
                                                            if(total3 >= 3000){
                                                                if(rowSize3 >= 3){
                                                                    cu3.setLevelCopy4Id(4);
                                                                    customerDao.update(cu3);

                                                                    if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                                        Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                                        if (cu4 != null) {
                                                                            // 判断王者是否升V4
                                                                            // 查询下级是否有9000单同时拥有3个V3
                                                                            int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                            int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                            if(total4 >= 9000){
                                                                                if(rowSize4 >= 3){
                                                                                    cu4.setLevelCopy4Id(5);
                                                                                    customerDao.update(cu4);

                                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                        if(cu5 != null) {
                                                                                            // 判断王者是否升V5
                                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                            if(total5 >= 27000){
                                                                                                if(rowSize5 >= 3){
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }

                                                                                                }else {
                                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                    if (queryList5.size() > 0) {
                                                                                                        int index5 = rowSize5;
                                                                                                        for (Customer c5 : queryList5) {
                                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                            if (temp5 > 0) {
                                                                                                                c5.setLevelV4("1");
                                                                                                                customerDao.update(c5);
                                                                                                            }
                                                                                                            index5 += temp5;
                                                                                                            if (index5 >= 3) {
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }

                                                                                }else {
                                                                                    List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                                    if (queryList4.size() > 0) {
                                                                                        int index4 = rowSize4;
                                                                                        for (Customer c4 : queryList4) {
                                                                                            int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                            if (temp4 > 0) {
                                                                                                c4.setLevelV3("1");
                                                                                                customerDao.update(c4);
                                                                                            }
                                                                                            index4 += temp4;
                                                                                            if (index4 >= 3) {
                                                                                                cu4.setLevelCopy4Id(5);
                                                                                                customerDao.update(cu4);

                                                                                                if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                                    Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                                    if(cu5 != null) {
                                                                                                        // 判断王者是否升V5
                                                                                                        // 查询下级是否有27000单同时拥有3个V4
                                                                                                        int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                                        int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                                        if(total5 >= 27000){
                                                                                                            if(rowSize5 >= 3){
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                            }else {
                                                                                                                List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                                if (queryList5.size() > 0) {
                                                                                                                    int index5 = rowSize5;
                                                                                                                    for (Customer c5 : queryList5) {
                                                                                                                        int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                                        if (temp5 > 0) {
                                                                                                                            c5.setLevelV4("1");
                                                                                                                            customerDao.update(c5);
                                                                                                                        }
                                                                                                                        index5 += temp5;
                                                                                                                        if (index5 >= 3) {
                                                                                                                            cu5.setLevelCopy4Id(6);
                                                                                                                            customerDao.update(cu5);

                                                                                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                                if(cu6 != null) {
                                                                                                                                    // 判断王者是否升V6
                                                                                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                                    if(total6 >= 81000){
                                                                                                                                        if(rowSize6 >= 3){
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);

                                                                                                                                        }else {
                                                                                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                            if (queryList6.size() > 0) {
                                                                                                                                                int index6 = rowSize6;
                                                                                                                                                for (Customer c6 : queryList6) {
                                                                                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                                    if (temp6 > 0) {
                                                                                                                                                        c6.setLevelV5("1");
                                                                                                                                                        customerDao.update(c6);
                                                                                                                                                    }
                                                                                                                                                    index6 += temp6;
                                                                                                                                                    if (index6 >= 3) {
                                                                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                                                                        customerDao.update(cu6);
                                                                                                                                                        break;
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                            break;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                break;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }

                                                                }else {
                                                                    List<Customer> queryList3 = customerDao.queryCustomerByLevelCopy4Id(3, cu3.getId());
                                                                    if (queryList3.size() > 0) {
                                                                        int index3 = rowSize3;
                                                                        for (Customer c3 : queryList3) {
                                                                            int temp3 = customerService.recursionCustomer_4(3, c3.getId());
                                                                            if (temp3 > 0) {
                                                                                c3.setLevelV2("1");
                                                                                customerDao.update(c3);
                                                                            }
                                                                            index3 += temp3;
                                                                            if (index3 >= 3) {
                                                                                cu3.setLevelCopy4Id(4);
                                                                                customerDao.update(cu3);

                                                                                if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                                                    Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                                                    if (cu4 != null) {
                                                                                        // 判断王者是否升V4
                                                                                        // 查询下级是否有9000单同时拥有3个V3
                                                                                        int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                                        int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                                        if(total4 >= 9000){
                                                                                            if(rowSize4 >= 3){
                                                                                                cu4.setLevelCopy4Id(5);
                                                                                                customerDao.update(cu4);

                                                                                                if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                                    Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                                    if(cu5 != null) {
                                                                                                        // 判断王者是否升V5
                                                                                                        // 查询下级是否有27000单同时拥有3个V4
                                                                                                        int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                                        int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                                        if(total5 >= 27000){
                                                                                                            if(rowSize5 >= 3){
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                            }else {
                                                                                                                List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                                if (queryList5.size() > 0) {
                                                                                                                    int index5 = rowSize5;
                                                                                                                    for (Customer c5 : queryList5) {
                                                                                                                        int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                                        if (temp5 > 0) {
                                                                                                                            c5.setLevelV4("1");
                                                                                                                            customerDao.update(c5);
                                                                                                                        }
                                                                                                                        index5 += temp5;
                                                                                                                        if (index5 >= 3) {
                                                                                                                            cu5.setLevelCopy4Id(6);
                                                                                                                            customerDao.update(cu5);

                                                                                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                                if(cu6 != null) {
                                                                                                                                    // 判断王者是否升V6
                                                                                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                                    if(total6 >= 81000){
                                                                                                                                        if(rowSize6 >= 3){
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);

                                                                                                                                        }else {
                                                                                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                            if (queryList6.size() > 0) {
                                                                                                                                                int index6 = rowSize6;
                                                                                                                                                for (Customer c6 : queryList6) {
                                                                                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                                    if (temp6 > 0) {
                                                                                                                                                        c6.setLevelV5("1");
                                                                                                                                                        customerDao.update(c6);
                                                                                                                                                    }
                                                                                                                                                    index6 += temp6;
                                                                                                                                                    if (index6 >= 3) {
                                                                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                                                                        customerDao.update(cu6);
                                                                                                                                                        break;
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                            break;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                            }else {
                                                                                                List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                                                if (queryList4.size() > 0) {
                                                                                                    int index4 = rowSize4;
                                                                                                    for (Customer c4 : queryList4) {
                                                                                                        int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                                        if (temp4 > 0) {
                                                                                                            c4.setLevelV3("1");
                                                                                                            customerDao.update(c4);
                                                                                                        }
                                                                                                        index4 += temp4;
                                                                                                        if (index4 >= 3) {
                                                                                                            cu4.setLevelCopy4Id(5);
                                                                                                            customerDao.update(cu4);

                                                                                                            if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                                                Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                                                if(cu5 != null) {
                                                                                                                    // 判断王者是否升V5
                                                                                                                    // 查询下级是否有27000单同时拥有3个V4
                                                                                                                    int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                                                    int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                                                    if(total5 >= 27000){
                                                                                                                        if(rowSize5 >= 3){
                                                                                                                            cu5.setLevelCopy4Id(6);
                                                                                                                            customerDao.update(cu5);

                                                                                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                                if(cu6 != null) {
                                                                                                                                    // 判断王者是否升V6
                                                                                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                                    if(total6 >= 81000){
                                                                                                                                        if(rowSize6 >= 3){
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);

                                                                                                                                        }else {
                                                                                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                            if (queryList6.size() > 0) {
                                                                                                                                                int index6 = rowSize6;
                                                                                                                                                for (Customer c6 : queryList6) {
                                                                                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                                    if (temp6 > 0) {
                                                                                                                                                        c6.setLevelV5("1");
                                                                                                                                                        customerDao.update(c6);
                                                                                                                                                    }
                                                                                                                                                    index6 += temp6;
                                                                                                                                                    if (index6 >= 3) {
                                                                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                                                                        customerDao.update(cu6);
                                                                                                                                                        break;
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }

                                                                                                                        }else {
                                                                                                                            List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                                            if (queryList5.size() > 0) {
                                                                                                                                int index5 = rowSize5;
                                                                                                                                for (Customer c5 : queryList5) {
                                                                                                                                    int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                                                    if (temp5 > 0) {
                                                                                                                                        c5.setLevelV4("1");
                                                                                                                                        customerDao.update(c5);
                                                                                                                                    }
                                                                                                                                    index5 += temp5;
                                                                                                                                    if (index5 >= 3) {
                                                                                                                                        cu5.setLevelCopy4Id(6);
                                                                                                                                        customerDao.update(cu5);

                                                                                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                                            if(cu6 != null) {
                                                                                                                                                // 判断王者是否升V6
                                                                                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                                                if(total6 >= 81000){
                                                                                                                                                    if(rowSize6 >= 3){
                                                                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                                                                        customerDao.update(cu6);

                                                                                                                                                    }else {
                                                                                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                                        if (queryList6.size() > 0) {
                                                                                                                                                            int index6 = rowSize6;
                                                                                                                                                            for (Customer c6 : queryList6) {
                                                                                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                                                if (temp6 > 0) {
                                                                                                                                                                    c6.setLevelV5("1");
                                                                                                                                                                    customerDao.update(c6);
                                                                                                                                                                }
                                                                                                                                                                index6 += temp6;
                                                                                                                                                                if (index6 >= 3) {
                                                                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                                                                    customerDao.update(cu6);
                                                                                                                                                                    break;
                                                                                                                                                                }
                                                                                                                                                            }
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                        break;
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            break;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                                break;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                }else if(cu1.getLevelCopy4Id() == 2){ //v1
                    // 判断是否升V2
                    // 查询下级是否有500单同时拥有3个V1
                    int total2 = customerDao.queryByOrderQuantityTotal(cu1.getId());
                    int rowSize2 = customerDao.queryByLevelV2(2, cu1.getId());
                    if(total2 >= 500){
                        if(rowSize2 >= 3){
                            cu1.setLevelCopy4Id(3);
                            customerDao.update(cu1);

                            if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                                Customer cu3 = customerDao.queryById(cu1.getParentId());
                                if(cu3 != null){
                                    // 判断王者是否升V3
                                    // 查询下级是否有3000单同时拥有3个V2
                                    int total3 = customerDao.queryByOrderQuantityTotal(cu3.getId());
                                    int rowSize3 = customerDao.queryByLevelV3(3, cu3.getId());
                                    if(total3 >= 3000){
                                        if(rowSize3 >= 3){
                                            cu3.setLevelCopy4Id(4);
                                            customerDao.update(cu3);

                                            if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                if (cu4 != null) {
                                                    // 判断王者是否升V4
                                                    // 查询下级是否有9000单同时拥有3个V3
                                                    int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                    int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                    if(total4 >= 9000){
                                                        if(rowSize4 >= 3){
                                                            cu4.setLevelCopy4Id(5);
                                                            customerDao.update(cu4);

                                                            if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                if(cu5 != null) {
                                                                    // 判断王者是否升V5
                                                                    // 查询下级是否有27000单同时拥有3个V4
                                                                    int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                    int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                    if(total5 >= 27000){
                                                                        if(rowSize5 >= 3){
                                                                            cu5.setLevelCopy4Id(6);
                                                                            customerDao.update(cu5);

                                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                if(cu6 != null) {
                                                                                    // 判断王者是否升V6
                                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                    if(total6 >= 81000){
                                                                                        if(rowSize6 >= 3){
                                                                                            cu6.setLevelCopy4Id(7);
                                                                                            customerDao.update(cu6);

                                                                                        }else {
                                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                            if (queryList6.size() > 0) {
                                                                                                int index6 = rowSize6;
                                                                                                for (Customer c6 : queryList6) {
                                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                    if (temp6 > 0) {
                                                                                                        c6.setLevelV5("1");
                                                                                                        customerDao.update(c6);
                                                                                                    }
                                                                                                    index6 += temp6;
                                                                                                    if (index6 >= 3) {
                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                        customerDao.update(cu6);
                                                                                                        break;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }

                                                                        }else {
                                                                            List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                            if (queryList5.size() > 0) {
                                                                                int index5 = rowSize5;
                                                                                for (Customer c5 : queryList5) {
                                                                                    int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                    if (temp5 > 0) {
                                                                                        c5.setLevelV4("1");
                                                                                        customerDao.update(c5);
                                                                                    }
                                                                                    index5 += temp5;
                                                                                    if (index5 >= 3) {
                                                                                        cu5.setLevelCopy4Id(6);
                                                                                        customerDao.update(cu5);

                                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                            if(cu6 != null) {
                                                                                                // 判断王者是否升V6
                                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                if(total6 >= 81000){
                                                                                                    if(rowSize6 >= 3){
                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                        customerDao.update(cu6);

                                                                                                    }else {
                                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                        if (queryList6.size() > 0) {
                                                                                                            int index6 = rowSize6;
                                                                                                            for (Customer c6 : queryList6) {
                                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                if (temp6 > 0) {
                                                                                                                    c6.setLevelV5("1");
                                                                                                                    customerDao.update(c6);
                                                                                                                }
                                                                                                                index6 += temp6;
                                                                                                                if (index6 >= 3) {
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);
                                                                                                                    break;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        break;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                        }else {
                                                            List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                            if (queryList4.size() > 0) {
                                                                int index4 = rowSize4;
                                                                for (Customer c4 : queryList4) {
                                                                    int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                    if (temp4 > 0) {
                                                                        c4.setLevelV3("1");
                                                                        customerDao.update(c4);
                                                                    }
                                                                    index4 += temp4;
                                                                    if (index4 >= 3) {
                                                                        cu4.setLevelCopy4Id(5);
                                                                        customerDao.update(cu4);

                                                                        if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                            Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                            if(cu5 != null) {
                                                                                // 判断王者是否升V5
                                                                                // 查询下级是否有27000单同时拥有3个V4
                                                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                if(total5 >= 27000){
                                                                                    if(rowSize5 >= 3){
                                                                                        cu5.setLevelCopy4Id(6);
                                                                                        customerDao.update(cu5);

                                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                            if(cu6 != null) {
                                                                                                // 判断王者是否升V6
                                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                if(total6 >= 81000){
                                                                                                    if(rowSize6 >= 3){
                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                        customerDao.update(cu6);

                                                                                                    }else {
                                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                        if (queryList6.size() > 0) {
                                                                                                            int index6 = rowSize6;
                                                                                                            for (Customer c6 : queryList6) {
                                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                if (temp6 > 0) {
                                                                                                                    c6.setLevelV5("1");
                                                                                                                    customerDao.update(c6);
                                                                                                                }
                                                                                                                index6 += temp6;
                                                                                                                if (index6 >= 3) {
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);
                                                                                                                    break;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }

                                                                                    }else {
                                                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                        if (queryList5.size() > 0) {
                                                                                            int index5 = rowSize5;
                                                                                            for (Customer c5 : queryList5) {
                                                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                if (temp5 > 0) {
                                                                                                    c5.setLevelV4("1");
                                                                                                    customerDao.update(c5);
                                                                                                }
                                                                                                index5 += temp5;
                                                                                                if (index5 >= 3) {
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                        }else {
                                            List<Customer> queryList3 = customerDao.queryCustomerByLevelCopy4Id(3, cu3.getId());
                                            if (queryList3.size() > 0) {
                                                int index3 = rowSize3;
                                                for (Customer c3 : queryList3) {
                                                    int temp3 = customerService.recursionCustomer_4(3, c3.getId());
                                                    if (temp3 > 0) {
                                                        c3.setLevelV2("1");
                                                        customerDao.update(c3);
                                                    }
                                                    index3 += temp3;
                                                    if (index3 >= 3) {
                                                        cu3.setLevelCopy4Id(4);
                                                        customerDao.update(cu3);

                                                        if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                            Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                            if (cu4 != null) {
                                                                // 判断王者是否升V4
                                                                // 查询下级是否有9000单同时拥有3个V3
                                                                int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                if(total4 >= 9000){
                                                                    if(rowSize4 >= 3){
                                                                        cu4.setLevelCopy4Id(5);
                                                                        customerDao.update(cu4);

                                                                        if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                            Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                            if(cu5 != null) {
                                                                                // 判断王者是否升V5
                                                                                // 查询下级是否有27000单同时拥有3个V4
                                                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                if(total5 >= 27000){
                                                                                    if(rowSize5 >= 3){
                                                                                        cu5.setLevelCopy4Id(6);
                                                                                        customerDao.update(cu5);

                                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                            if(cu6 != null) {
                                                                                                // 判断王者是否升V6
                                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                if(total6 >= 81000){
                                                                                                    if(rowSize6 >= 3){
                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                        customerDao.update(cu6);

                                                                                                    }else {
                                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                        if (queryList6.size() > 0) {
                                                                                                            int index6 = rowSize6;
                                                                                                            for (Customer c6 : queryList6) {
                                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                if (temp6 > 0) {
                                                                                                                    c6.setLevelV5("1");
                                                                                                                    customerDao.update(c6);
                                                                                                                }
                                                                                                                index6 += temp6;
                                                                                                                if (index6 >= 3) {
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);
                                                                                                                    break;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }

                                                                                    }else {
                                                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                        if (queryList5.size() > 0) {
                                                                                            int index5 = rowSize5;
                                                                                            for (Customer c5 : queryList5) {
                                                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                if (temp5 > 0) {
                                                                                                    c5.setLevelV4("1");
                                                                                                    customerDao.update(c5);
                                                                                                }
                                                                                                index5 += temp5;
                                                                                                if (index5 >= 3) {
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                    }else {
                                                                        List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                        if (queryList4.size() > 0) {
                                                                            int index4 = rowSize4;
                                                                            for (Customer c4 : queryList4) {
                                                                                int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                if (temp4 > 0) {
                                                                                    c4.setLevelV3("1");
                                                                                    customerDao.update(c4);
                                                                                }
                                                                                index4 += temp4;
                                                                                if (index4 >= 3) {
                                                                                    cu4.setLevelCopy4Id(5);
                                                                                    customerDao.update(cu4);

                                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                        if(cu5 != null) {
                                                                                            // 判断王者是否升V5
                                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                            if(total5 >= 27000){
                                                                                                if(rowSize5 >= 3){
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }

                                                                                                }else {
                                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                    if (queryList5.size() > 0) {
                                                                                                        int index5 = rowSize5;
                                                                                                        for (Customer c5 : queryList5) {
                                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                            if (temp5 > 0) {
                                                                                                                c5.setLevelV4("1");
                                                                                                                customerDao.update(c5);
                                                                                                            }
                                                                                                            index5 += temp5;
                                                                                                            if (index5 >= 3) {
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }else {
                            List<Customer> queryList2 = customerDao.queryCustomerByLevelCopy4Id(2, cu1.getId());
                            if (queryList2.size() > 0) {
                                int index2 = rowSize2;
                                for (Customer c2 : queryList2) {
                                    int temp2 = customerService.recursionCustomer_4(2, c2.getId());
                                    if (temp2 > 0) {
                                        c2.setLevelV1("1");
                                        customerDao.update(c2);
                                    }
                                    index2 += temp2;
                                    if (index2 >= 3) {
                                        cu1.setLevelCopy4Id(3);
                                        customerDao.update(cu1);

                                        if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                                            Customer cu3 = customerDao.queryById(cu1.getParentId());
                                            if(cu3 != null){
                                                // 判断王者是否升V3
                                                // 查询下级是否有3000单同时拥有3个V2
                                                int total3 = customerDao.queryByOrderQuantityTotal(cu3.getId());
                                                int rowSize3 = customerDao.queryByLevelV3(3, cu3.getId());
                                                if(total3 >= 3000){
                                                    if(rowSize3 >= 3){
                                                        cu3.setLevelCopy4Id(4);
                                                        customerDao.update(cu3);

                                                        if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                            Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                            if (cu4 != null) {
                                                                // 判断王者是否升V4
                                                                // 查询下级是否有9000单同时拥有3个V3
                                                                int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                if(total4 >= 9000){
                                                                    if(rowSize4 >= 3){
                                                                        cu4.setLevelCopy4Id(5);
                                                                        customerDao.update(cu4);

                                                                        if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                            Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                            if(cu5 != null) {
                                                                                // 判断王者是否升V5
                                                                                // 查询下级是否有27000单同时拥有3个V4
                                                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                if(total5 >= 27000){
                                                                                    if(rowSize5 >= 3){
                                                                                        cu5.setLevelCopy4Id(6);
                                                                                        customerDao.update(cu5);

                                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                            if(cu6 != null) {
                                                                                                // 判断王者是否升V6
                                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                if(total6 >= 81000){
                                                                                                    if(rowSize6 >= 3){
                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                        customerDao.update(cu6);

                                                                                                    }else {
                                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                        if (queryList6.size() > 0) {
                                                                                                            int index6 = rowSize6;
                                                                                                            for (Customer c6 : queryList6) {
                                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                if (temp6 > 0) {
                                                                                                                    c6.setLevelV5("1");
                                                                                                                    customerDao.update(c6);
                                                                                                                }
                                                                                                                index6 += temp6;
                                                                                                                if (index6 >= 3) {
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);
                                                                                                                    break;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }

                                                                                    }else {
                                                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                        if (queryList5.size() > 0) {
                                                                                            int index5 = rowSize5;
                                                                                            for (Customer c5 : queryList5) {
                                                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                if (temp5 > 0) {
                                                                                                    c5.setLevelV4("1");
                                                                                                    customerDao.update(c5);
                                                                                                }
                                                                                                index5 += temp5;
                                                                                                if (index5 >= 3) {
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                    }else {
                                                                        List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                        if (queryList4.size() > 0) {
                                                                            int index4 = rowSize4;
                                                                            for (Customer c4 : queryList4) {
                                                                                int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                if (temp4 > 0) {
                                                                                    c4.setLevelV3("1");
                                                                                    customerDao.update(c4);
                                                                                }
                                                                                index4 += temp4;
                                                                                if (index4 >= 3) {
                                                                                    cu4.setLevelCopy4Id(5);
                                                                                    customerDao.update(cu4);

                                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                        if(cu5 != null) {
                                                                                            // 判断王者是否升V5
                                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                            if(total5 >= 27000){
                                                                                                if(rowSize5 >= 3){
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }

                                                                                                }else {
                                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                    if (queryList5.size() > 0) {
                                                                                                        int index5 = rowSize5;
                                                                                                        for (Customer c5 : queryList5) {
                                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                            if (temp5 > 0) {
                                                                                                                c5.setLevelV4("1");
                                                                                                                customerDao.update(c5);
                                                                                                            }
                                                                                                            index5 += temp5;
                                                                                                            if (index5 >= 3) {
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                    }else {
                                                        List<Customer> queryList3 = customerDao.queryCustomerByLevelCopy4Id(3, cu3.getId());
                                                        if (queryList3.size() > 0) {
                                                            int index3 = rowSize3;
                                                            for (Customer c3 : queryList3) {
                                                                int temp3 = customerService.recursionCustomer_4(3, c3.getId());
                                                                if (temp3 > 0) {
                                                                    c3.setLevelV2("1");
                                                                    customerDao.update(c3);
                                                                }
                                                                index3 += temp3;
                                                                if (index3 >= 3) {
                                                                    cu3.setLevelCopy4Id(4);
                                                                    customerDao.update(cu3);

                                                                    if(cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopy4Id() != 8) {
                                                                        Customer cu4 = customerDao.queryById(cu3.getParentId());
                                                                        if (cu4 != null) {
                                                                            // 判断王者是否升V4
                                                                            // 查询下级是否有9000单同时拥有3个V3
                                                                            int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                                            int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                                            if(total4 >= 9000){
                                                                                if(rowSize4 >= 3){
                                                                                    cu4.setLevelCopy4Id(5);
                                                                                    customerDao.update(cu4);

                                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                        if(cu5 != null) {
                                                                                            // 判断王者是否升V5
                                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                            if(total5 >= 27000){
                                                                                                if(rowSize5 >= 3){
                                                                                                    cu5.setLevelCopy4Id(6);
                                                                                                    customerDao.update(cu5);

                                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                        if(cu6 != null) {
                                                                                                            // 判断王者是否升V6
                                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                            if(total6 >= 81000){
                                                                                                                if(rowSize6 >= 3){
                                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                                    customerDao.update(cu6);

                                                                                                                }else {
                                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                    if (queryList6.size() > 0) {
                                                                                                                        int index6 = rowSize6;
                                                                                                                        for (Customer c6 : queryList6) {
                                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                            if (temp6 > 0) {
                                                                                                                                c6.setLevelV5("1");
                                                                                                                                customerDao.update(c6);
                                                                                                                            }
                                                                                                                            index6 += temp6;
                                                                                                                            if (index6 >= 3) {
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);
                                                                                                                                break;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }

                                                                                                }else {
                                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                    if (queryList5.size() > 0) {
                                                                                                        int index5 = rowSize5;
                                                                                                        for (Customer c5 : queryList5) {
                                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                            if (temp5 > 0) {
                                                                                                                c5.setLevelV4("1");
                                                                                                                customerDao.update(c5);
                                                                                                            }
                                                                                                            index5 += temp5;
                                                                                                            if (index5 >= 3) {
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }

                                                                                }else {
                                                                                    List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                                                    if (queryList4.size() > 0) {
                                                                                        int index4 = rowSize4;
                                                                                        for (Customer c4 : queryList4) {
                                                                                            int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                                            if (temp4 > 0) {
                                                                                                c4.setLevelV3("1");
                                                                                                customerDao.update(c4);
                                                                                            }
                                                                                            index4 += temp4;
                                                                                            if (index4 >= 3) {
                                                                                                cu4.setLevelCopy4Id(5);
                                                                                                customerDao.update(cu4);

                                                                                                if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                                                    Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                                                    if(cu5 != null) {
                                                                                                        // 判断王者是否升V5
                                                                                                        // 查询下级是否有27000单同时拥有3个V4
                                                                                                        int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                                                        int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                                                        if(total5 >= 27000){
                                                                                                            if(rowSize5 >= 3){
                                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                                customerDao.update(cu5);

                                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                    if(cu6 != null) {
                                                                                                                        // 判断王者是否升V6
                                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                        if(total6 >= 81000){
                                                                                                                            if(rowSize6 >= 3){
                                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                                customerDao.update(cu6);

                                                                                                                            }else {
                                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                if (queryList6.size() > 0) {
                                                                                                                                    int index6 = rowSize6;
                                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                        if (temp6 > 0) {
                                                                                                                                            c6.setLevelV5("1");
                                                                                                                                            customerDao.update(c6);
                                                                                                                                        }
                                                                                                                                        index6 += temp6;
                                                                                                                                        if (index6 >= 3) {
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);
                                                                                                                                            break;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }

                                                                                                            }else {
                                                                                                                List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                                                if (queryList5.size() > 0) {
                                                                                                                    int index5 = rowSize5;
                                                                                                                    for (Customer c5 : queryList5) {
                                                                                                                        int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                                                        if (temp5 > 0) {
                                                                                                                            c5.setLevelV4("1");
                                                                                                                            customerDao.update(c5);
                                                                                                                        }
                                                                                                                        index5 += temp5;
                                                                                                                        if (index5 >= 3) {
                                                                                                                            cu5.setLevelCopy4Id(6);
                                                                                                                            customerDao.update(cu5);

                                                                                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                                                if(cu6 != null) {
                                                                                                                                    // 判断王者是否升V6
                                                                                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                                                    if(total6 >= 81000){
                                                                                                                                        if(rowSize6 >= 3){
                                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                                            customerDao.update(cu6);

                                                                                                                                        }else {
                                                                                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                                            if (queryList6.size() > 0) {
                                                                                                                                                int index6 = rowSize6;
                                                                                                                                                for (Customer c6 : queryList6) {
                                                                                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                                                    if (temp6 > 0) {
                                                                                                                                                        c6.setLevelV5("1");
                                                                                                                                                        customerDao.update(c6);
                                                                                                                                                    }
                                                                                                                                                    index6 += temp6;
                                                                                                                                                    if (index6 >= 3) {
                                                                                                                                                        cu6.setLevelCopy4Id(7);
                                                                                                                                                        customerDao.update(cu6);
                                                                                                                                                        break;
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                            break;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                break;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }

                }else if(cu1.getLevelCopy4Id() == 3){ // v2
                    // 判断是否升V3
                    // 查询下级是否有3000单同时拥有3个V2
                    int total3 = customerDao.queryByOrderQuantityTotal(cu1.getId());
                    int rowSize3 = customerDao.queryByLevelV3(3, cu1.getId());
                    if(total3 >= 3000){
                        if(rowSize3 >= 3){
                            cu1.setLevelCopy4Id(4);
                            customerDao.update(cu1);

                            if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8) {
                                Customer cu4 = customerDao.queryById(cu1.getParentId());
                                if (cu4 != null) {
                                    // 判断王者是否升V4
                                    // 查询下级是否有9000单同时拥有3个V3
                                    int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                    int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                    if(total4 >= 9000){
                                        if(rowSize4 >= 3){
                                            cu4.setLevelCopy4Id(5);
                                            customerDao.update(cu4);

                                            if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                if(cu5 != null) {
                                                    // 判断王者是否升V5
                                                    // 查询下级是否有27000单同时拥有3个V4
                                                    int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                    int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                    if(total5 >= 27000){
                                                        if(rowSize5 >= 3){
                                                            cu5.setLevelCopy4Id(6);
                                                            customerDao.update(cu5);

                                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                if(cu6 != null) {
                                                                    // 判断王者是否升V6
                                                                    // 查询下级是否有81000单同时拥有3个V5
                                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                    if(total6 >= 81000){
                                                                        if(rowSize6 >= 3){
                                                                            cu6.setLevelCopy4Id(7);
                                                                            customerDao.update(cu6);

                                                                        }else {
                                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                            if (queryList6.size() > 0) {
                                                                                int index6 = rowSize6;
                                                                                for (Customer c6 : queryList6) {
                                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                    if (temp6 > 0) {
                                                                                        c6.setLevelV5("1");
                                                                                        customerDao.update(c6);
                                                                                    }
                                                                                    index6 += temp6;
                                                                                    if (index6 >= 3) {
                                                                                        cu6.setLevelCopy4Id(7);
                                                                                        customerDao.update(cu6);
                                                                                        break;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                        }else {
                                                            List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                            if (queryList5.size() > 0) {
                                                                int index5 = rowSize5;
                                                                for (Customer c5 : queryList5) {
                                                                    int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                    if (temp5 > 0) {
                                                                        c5.setLevelV4("1");
                                                                        customerDao.update(c5);
                                                                    }
                                                                    index5 += temp5;
                                                                    if (index5 >= 3) {
                                                                        cu5.setLevelCopy4Id(6);
                                                                        customerDao.update(cu5);

                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                            if(cu6 != null) {
                                                                                // 判断王者是否升V6
                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                if(total6 >= 81000){
                                                                                    if(rowSize6 >= 3){
                                                                                        cu6.setLevelCopy4Id(7);
                                                                                        customerDao.update(cu6);

                                                                                    }else {
                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                        if (queryList6.size() > 0) {
                                                                                            int index6 = rowSize6;
                                                                                            for (Customer c6 : queryList6) {
                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                if (temp6 > 0) {
                                                                                                    c6.setLevelV5("1");
                                                                                                    customerDao.update(c6);
                                                                                                }
                                                                                                index6 += temp6;
                                                                                                if (index6 >= 3) {
                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                    customerDao.update(cu6);
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                        }else {
                                            List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                            if (queryList4.size() > 0) {
                                                int index4 = rowSize4;
                                                for (Customer c4 : queryList4) {
                                                    int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                    if (temp4 > 0) {
                                                        c4.setLevelV3("1");
                                                        customerDao.update(c4);
                                                    }
                                                    index4 += temp4;
                                                    if (index4 >= 3) {
                                                        cu4.setLevelCopy4Id(5);
                                                        customerDao.update(cu4);

                                                        if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                            Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                            if(cu5 != null) {
                                                                // 判断王者是否升V5
                                                                // 查询下级是否有27000单同时拥有3个V4
                                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                if(total5 >= 27000){
                                                                    if(rowSize5 >= 3){
                                                                        cu5.setLevelCopy4Id(6);
                                                                        customerDao.update(cu5);

                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                            if(cu6 != null) {
                                                                                // 判断王者是否升V6
                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                if(total6 >= 81000){
                                                                                    if(rowSize6 >= 3){
                                                                                        cu6.setLevelCopy4Id(7);
                                                                                        customerDao.update(cu6);

                                                                                    }else {
                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                        if (queryList6.size() > 0) {
                                                                                            int index6 = rowSize6;
                                                                                            for (Customer c6 : queryList6) {
                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                if (temp6 > 0) {
                                                                                                    c6.setLevelV5("1");
                                                                                                    customerDao.update(c6);
                                                                                                }
                                                                                                index6 += temp6;
                                                                                                if (index6 >= 3) {
                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                    customerDao.update(cu6);
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                    }else {
                                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                        if (queryList5.size() > 0) {
                                                                            int index5 = rowSize5;
                                                                            for (Customer c5 : queryList5) {
                                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                if (temp5 > 0) {
                                                                                    c5.setLevelV4("1");
                                                                                    customerDao.update(c5);
                                                                                }
                                                                                index5 += temp5;
                                                                                if (index5 >= 3) {
                                                                                    cu5.setLevelCopy4Id(6);
                                                                                    customerDao.update(cu5);

                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                        if(cu6 != null) {
                                                                                            // 判断王者是否升V6
                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                            if(total6 >= 81000){
                                                                                                if(rowSize6 >= 3){
                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                    customerDao.update(cu6);

                                                                                                }else {
                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                    if (queryList6.size() > 0) {
                                                                                                        int index6 = rowSize6;
                                                                                                        for (Customer c6 : queryList6) {
                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                            if (temp6 > 0) {
                                                                                                                c6.setLevelV5("1");
                                                                                                                customerDao.update(c6);
                                                                                                            }
                                                                                                            index6 += temp6;
                                                                                                            if (index6 >= 3) {
                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                customerDao.update(cu6);
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }else {
                            List<Customer> queryList3 = customerDao.queryCustomerByLevelCopy4Id(3, cu1.getId());
                            if (queryList3.size() > 0) {
                                int index3 = rowSize3;
                                for (Customer c3 : queryList3) {
                                    int temp3 = customerService.recursionCustomer_4(3, c3.getId());
                                    if (temp3 > 0) {
                                        c3.setLevelV2("1");
                                        customerDao.update(c3);
                                    }
                                    index3 += temp3;
                                    if (index3 >= 3) {
                                        cu1.setLevelCopy4Id(4);
                                        customerDao.update(cu1);

                                        if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8) {
                                            Customer cu4 = customerDao.queryById(cu1.getParentId());
                                            if (cu4 != null) {
                                                // 判断王者是否升V4
                                                // 查询下级是否有9000单同时拥有3个V3
                                                int total4 = customerDao.queryByOrderQuantityTotal(cu4.getId());
                                                int rowSize4 = customerDao.queryByLevelV4(4, cu4.getId());
                                                if(total4 >= 9000){
                                                    if(rowSize4 >= 3){
                                                        cu4.setLevelCopy4Id(5);
                                                        customerDao.update(cu4);

                                                        if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                            Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                            if(cu5 != null) {
                                                                // 判断王者是否升V5
                                                                // 查询下级是否有27000单同时拥有3个V4
                                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                if(total5 >= 27000){
                                                                    if(rowSize5 >= 3){
                                                                        cu5.setLevelCopy4Id(6);
                                                                        customerDao.update(cu5);

                                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                            if(cu6 != null) {
                                                                                // 判断王者是否升V6
                                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                if(total6 >= 81000){
                                                                                    if(rowSize6 >= 3){
                                                                                        cu6.setLevelCopy4Id(7);
                                                                                        customerDao.update(cu6);

                                                                                    }else {
                                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                        if (queryList6.size() > 0) {
                                                                                            int index6 = rowSize6;
                                                                                            for (Customer c6 : queryList6) {
                                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                if (temp6 > 0) {
                                                                                                    c6.setLevelV5("1");
                                                                                                    customerDao.update(c6);
                                                                                                }
                                                                                                index6 += temp6;
                                                                                                if (index6 >= 3) {
                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                    customerDao.update(cu6);
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }

                                                                    }else {
                                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                        if (queryList5.size() > 0) {
                                                                            int index5 = rowSize5;
                                                                            for (Customer c5 : queryList5) {
                                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                if (temp5 > 0) {
                                                                                    c5.setLevelV4("1");
                                                                                    customerDao.update(c5);
                                                                                }
                                                                                index5 += temp5;
                                                                                if (index5 >= 3) {
                                                                                    cu5.setLevelCopy4Id(6);
                                                                                    customerDao.update(cu5);

                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                        if(cu6 != null) {
                                                                                            // 判断王者是否升V6
                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                            if(total6 >= 81000){
                                                                                                if(rowSize6 >= 3){
                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                    customerDao.update(cu6);

                                                                                                }else {
                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                    if (queryList6.size() > 0) {
                                                                                                        int index6 = rowSize6;
                                                                                                        for (Customer c6 : queryList6) {
                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                            if (temp6 > 0) {
                                                                                                                c6.setLevelV5("1");
                                                                                                                customerDao.update(c6);
                                                                                                            }
                                                                                                            index6 += temp6;
                                                                                                            if (index6 >= 3) {
                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                customerDao.update(cu6);
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                    }else {
                                                        List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu4.getId());
                                                        if (queryList4.size() > 0) {
                                                            int index4 = rowSize4;
                                                            for (Customer c4 : queryList4) {
                                                                int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                                                if (temp4 > 0) {
                                                                    c4.setLevelV3("1");
                                                                    customerDao.update(c4);
                                                                }
                                                                index4 += temp4;
                                                                if (index4 >= 3) {
                                                                    cu4.setLevelCopy4Id(5);
                                                                    customerDao.update(cu4);

                                                                    if(cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopy4Id() != 8){
                                                                        Customer cu5 = customerDao.queryById(cu4.getParentId());
                                                                        if(cu5 != null) {
                                                                            // 判断王者是否升V5
                                                                            // 查询下级是否有27000单同时拥有3个V4
                                                                            int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                                            int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                                            if(total5 >= 27000){
                                                                                if(rowSize5 >= 3){
                                                                                    cu5.setLevelCopy4Id(6);
                                                                                    customerDao.update(cu5);

                                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                        if(cu6 != null) {
                                                                                            // 判断王者是否升V6
                                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                            if(total6 >= 81000){
                                                                                                if(rowSize6 >= 3){
                                                                                                    cu6.setLevelCopy4Id(7);
                                                                                                    customerDao.update(cu6);

                                                                                                }else {
                                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                    if (queryList6.size() > 0) {
                                                                                                        int index6 = rowSize6;
                                                                                                        for (Customer c6 : queryList6) {
                                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                            if (temp6 > 0) {
                                                                                                                c6.setLevelV5("1");
                                                                                                                customerDao.update(c6);
                                                                                                            }
                                                                                                            index6 += temp6;
                                                                                                            if (index6 >= 3) {
                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                customerDao.update(cu6);
                                                                                                                break;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }

                                                                                }else {
                                                                                    List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                                                    if (queryList5.size() > 0) {
                                                                                        int index5 = rowSize5;
                                                                                        for (Customer c5 : queryList5) {
                                                                                            int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                                            if (temp5 > 0) {
                                                                                                c5.setLevelV4("1");
                                                                                                customerDao.update(c5);
                                                                                            }
                                                                                            index5 += temp5;
                                                                                            if (index5 >= 3) {
                                                                                                cu5.setLevelCopy4Id(6);
                                                                                                customerDao.update(cu5);

                                                                                                if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                                                    Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                                                    if(cu6 != null) {
                                                                                                        // 判断王者是否升V6
                                                                                                        // 查询下级是否有81000单同时拥有3个V5
                                                                                                        int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                                                        int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                                                        if(total6 >= 81000){
                                                                                                            if(rowSize6 >= 3){
                                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                                customerDao.update(cu6);

                                                                                                            }else {
                                                                                                                List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                                                if (queryList6.size() > 0) {
                                                                                                                    int index6 = rowSize6;
                                                                                                                    for (Customer c6 : queryList6) {
                                                                                                                        int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                                                        if (temp6 > 0) {
                                                                                                                            c6.setLevelV5("1");
                                                                                                                            customerDao.update(c6);
                                                                                                                        }
                                                                                                                        index6 += temp6;
                                                                                                                        if (index6 >= 3) {
                                                                                                                            cu6.setLevelCopy4Id(7);
                                                                                                                            customerDao.update(cu6);
                                                                                                                            break;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                break;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }

                }else if(cu1.getLevelCopy4Id() == 4){ // v3
                    // 判断是否升V4
                    // 查询下级是否有9000单同时拥有3个V3
                    int total4 = customerDao.queryByOrderQuantityTotal(cu1.getId());
                    int rowSize4 = customerDao.queryByLevelV4(4, cu1.getId());
                    if(total4 >= 9000){
                        if(rowSize4 >= 3){
                            cu1.setLevelCopy4Id(5);
                            customerDao.update(cu1);

                            if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                                Customer cu5 = customerDao.queryById(cu1.getParentId());
                                if(cu5 != null) {
                                    // 判断王者是否升V5
                                    // 查询下级是否有27000单同时拥有3个V4
                                    int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                    int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                    if(total5 >= 27000){
                                        if(rowSize5 >= 3){
                                            cu5.setLevelCopy4Id(6);
                                            customerDao.update(cu5);

                                            if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                if(cu6 != null) {
                                                    // 判断王者是否升V6
                                                    // 查询下级是否有81000单同时拥有3个V5
                                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                    if(total6 >= 81000){
                                                        if(rowSize6 >= 3){
                                                            cu6.setLevelCopy4Id(7);
                                                            customerDao.update(cu6);

                                                        }else {
                                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                            if (queryList6.size() > 0) {
                                                                int index6 = rowSize6;
                                                                for (Customer c6 : queryList6) {
                                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                    if (temp6 > 0) {
                                                                        c6.setLevelV5("1");
                                                                        customerDao.update(c6);
                                                                    }
                                                                    index6 += temp6;
                                                                    if (index6 >= 3) {
                                                                        cu6.setLevelCopy4Id(7);
                                                                        customerDao.update(cu6);
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                        }else {
                                            List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                            if (queryList5.size() > 0) {
                                                int index5 = rowSize5;
                                                for (Customer c5 : queryList5) {
                                                    int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                    if (temp5 > 0) {
                                                        c5.setLevelV4("1");
                                                        customerDao.update(c5);
                                                    }
                                                    index5 += temp5;
                                                    if (index5 >= 3) {
                                                        cu5.setLevelCopy4Id(6);
                                                        customerDao.update(cu5);

                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                            if(cu6 != null) {
                                                                // 判断王者是否升V6
                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                if(total6 >= 81000){
                                                                    if(rowSize6 >= 3){
                                                                        cu6.setLevelCopy4Id(7);
                                                                        customerDao.update(cu6);

                                                                    }else {
                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                        if (queryList6.size() > 0) {
                                                                            int index6 = rowSize6;
                                                                            for (Customer c6 : queryList6) {
                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                if (temp6 > 0) {
                                                                                    c6.setLevelV5("1");
                                                                                    customerDao.update(c6);
                                                                                }
                                                                                index6 += temp6;
                                                                                if (index6 >= 3) {
                                                                                    cu6.setLevelCopy4Id(7);
                                                                                    customerDao.update(cu6);
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }else {
                            List<Customer> queryList4 = customerDao.queryCustomerByLevelCopy4Id(4, cu1.getId());
                            if (queryList4.size() > 0) {
                                int index4 = rowSize4;
                                for (Customer c4 : queryList4) {
                                    int temp4 = customerService.recursionCustomer_4(4, c4.getId());
                                    if (temp4 > 0) {
                                        c4.setLevelV3("1");
                                        customerDao.update(c4);
                                    }
                                    index4 += temp4;
                                    if (index4 >= 3) {
                                        cu1.setLevelCopy4Id(5);
                                        customerDao.update(cu1);

                                        if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                                            Customer cu5 = customerDao.queryById(cu1.getParentId());
                                            if(cu5 != null) {
                                                // 判断王者是否升V5
                                                // 查询下级是否有27000单同时拥有3个V4
                                                int total5 = customerDao.queryByOrderQuantityTotal(cu5.getId());
                                                int rowSize5 = customerDao.queryByLevelV5(5, cu5.getId());
                                                if(total5 >= 27000){
                                                    if(rowSize5 >= 3){
                                                        cu5.setLevelCopy4Id(6);
                                                        customerDao.update(cu5);

                                                        if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                            Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                            if(cu6 != null) {
                                                                // 判断王者是否升V6
                                                                // 查询下级是否有81000单同时拥有3个V5
                                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                if(total6 >= 81000){
                                                                    if(rowSize6 >= 3){
                                                                        cu6.setLevelCopy4Id(7);
                                                                        customerDao.update(cu6);

                                                                    }else {
                                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                        if (queryList6.size() > 0) {
                                                                            int index6 = rowSize6;
                                                                            for (Customer c6 : queryList6) {
                                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                if (temp6 > 0) {
                                                                                    c6.setLevelV5("1");
                                                                                    customerDao.update(c6);
                                                                                }
                                                                                index6 += temp6;
                                                                                if (index6 >= 3) {
                                                                                    cu6.setLevelCopy4Id(7);
                                                                                    customerDao.update(cu6);
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                    }else {
                                                        List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu5.getId());
                                                        if (queryList5.size() > 0) {
                                                            int index5 = rowSize5;
                                                            for (Customer c5 : queryList5) {
                                                                int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                                                if (temp5 > 0) {
                                                                    c5.setLevelV4("1");
                                                                    customerDao.update(c5);
                                                                }
                                                                index5 += temp5;
                                                                if (index5 >= 3) {
                                                                    cu5.setLevelCopy4Id(6);
                                                                    customerDao.update(cu5);

                                                                    if(cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopy4Id() != 8){
                                                                        Customer cu6 = customerDao.queryById(cu5.getParentId());
                                                                        if(cu6 != null) {
                                                                            // 判断王者是否升V6
                                                                            // 查询下级是否有81000单同时拥有3个V5
                                                                            int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                                            int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                                            if(total6 >= 81000){
                                                                                if(rowSize6 >= 3){
                                                                                    cu6.setLevelCopy4Id(7);
                                                                                    customerDao.update(cu6);

                                                                                }else {
                                                                                    List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                                                    if (queryList6.size() > 0) {
                                                                                        int index6 = rowSize6;
                                                                                        for (Customer c6 : queryList6) {
                                                                                            int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                                            if (temp6 > 0) {
                                                                                                c6.setLevelV5("1");
                                                                                                customerDao.update(c6);
                                                                                            }
                                                                                            index6 += temp6;
                                                                                            if (index6 >= 3) {
                                                                                                cu6.setLevelCopy4Id(7);
                                                                                                customerDao.update(cu6);
                                                                                                break;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }

                }else if(cu1.getLevelCopy4Id() == 5){ // v4
                    // 判断是否升V5
                    // 查询下级是否有27000单同时拥有3个V4
                    int total5 = customerDao.queryByOrderQuantityTotal(cu1.getId());
                    int rowSize5 = customerDao.queryByLevelV5(5, cu1.getId());
                    if(total5 >= 27000){
                        if(rowSize5 >= 3){
                            cu1.setLevelCopy4Id(6);
                            customerDao.update(cu1);

                            if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                                Customer cu6 = customerDao.queryById(cu1.getParentId());
                                if(cu6 != null) {
                                    // 判断王者是否升V6
                                    // 查询下级是否有81000单同时拥有3个V5
                                    int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                    int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                    if(total6 >= 81000){
                                        if(rowSize6 >= 3){
                                            cu6.setLevelCopy4Id(7);
                                            customerDao.update(cu6);

                                        }else {
                                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                            if (queryList6.size() > 0) {
                                                int index6 = rowSize6;
                                                for (Customer c6 : queryList6) {
                                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                    if (temp6 > 0) {
                                                        c6.setLevelV5("1");
                                                        customerDao.update(c6);
                                                    }
                                                    index6 += temp6;
                                                    if (index6 >= 3) {
                                                        cu6.setLevelCopy4Id(7);
                                                        customerDao.update(cu6);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }else {
                            List<Customer> queryList5 = customerDao.queryCustomerByLevelCopy4Id(5, cu1.getId());
                            if (queryList5.size() > 0) {
                                int index5 = rowSize5;
                                for (Customer c5 : queryList5) {
                                    int temp5 = customerService.recursionCustomer_4(5, c5.getId());
                                    if (temp5 > 0) {
                                        c5.setLevelV4("1");
                                        customerDao.update(c5);
                                    }
                                    index5 += temp5;
                                    if (index5 >= 3) {
                                        cu1.setLevelCopy4Id(6);
                                        customerDao.update(cu1);

                                        if(cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopy4Id() != 8){
                                            Customer cu6 = customerDao.queryById(cu1.getParentId());
                                            if(cu6 != null) {
                                                // 判断王者是否升V6
                                                // 查询下级是否有81000单同时拥有3个V5
                                                int total6 = customerDao.queryByOrderQuantityTotal(cu6.getId());
                                                int rowSize6 = customerDao.queryByLevelV5(6, cu6.getId());
                                                if(total6 >= 81000){
                                                    if(rowSize6 >= 3){
                                                        cu6.setLevelCopy4Id(7);
                                                        customerDao.update(cu6);

                                                    }else {
                                                        List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu6.getId());
                                                        if (queryList6.size() > 0) {
                                                            int index6 = rowSize6;
                                                            for (Customer c6 : queryList6) {
                                                                int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                                                if (temp6 > 0) {
                                                                    c6.setLevelV5("1");
                                                                    customerDao.update(c6);
                                                                }
                                                                index6 += temp6;
                                                                if (index6 >= 3) {
                                                                    cu6.setLevelCopy4Id(7);
                                                                    customerDao.update(cu6);
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }

                }else if(cu1.getLevelCopy4Id() == 6){ // v5
                    // 判断是否升V6
                    // 查询下级是否有81000单同时拥有3个V5
                    int total6 = customerDao.queryByOrderQuantityTotal(cu1.getId());
                    int rowSize6 = customerDao.queryByLevelV5(6, cu1.getId());
                    if(total6 >= 81000){
                        if(rowSize6 >= 3){
                            cu1.setLevelCopy4Id(7);
                            customerDao.update(cu1);

                        }else {
                            List<Customer> queryList6 = customerDao.queryCustomerByLevelCopy4Id(6, cu1.getId());
                            if (queryList6.size() > 0) {
                                int index6 = rowSize6;
                                for (Customer c6 : queryList6) {
                                    int temp6 = customerService.recursionCustomer_4(6, c6.getId());
                                    if (temp6 > 0) {
                                        c6.setLevelV5("1");
                                        customerDao.update(c6);
                                    }
                                    index6 += temp6;
                                    if (index6 >= 3) {
                                        cu1.setLevelCopy4Id(7);
                                        customerDao.update(cu1);
                                        break;
                                    }
                                }
                            }
                        }
                    }

                }else if(cu1.getLevelCopy4Id() == 7){
                    // 不升级了

                }
            }
        }
    }


    /**
     * 共享模式 处理用户购买后添加业绩和单数
     * @param orders
     */
    public void addAchievementAndOrderQuantity(Orders orders){
        BigDecimal totalAmount = orders.getPayAmount(); // 实际支付的金额
        Integer orderQuantity = 0;
        if(totalAmount.doubleValue() >= 369 && totalAmount.doubleValue() < 3690){
            orderQuantity = 1;
        }else if(totalAmount.doubleValue() >= 3690 && totalAmount.doubleValue() < 36900){
            orderQuantity = 10;
        }else if(totalAmount.doubleValue() >= 36900){
            orderQuantity = 100;
        }

        // 添加业绩
        Customer customer = customerDao.queryById(orders.getOrderPersonId());
        if (customer != null) {
            customer.setAchievement3(customer.getAchievement3().add(totalAmount)); // 团队业绩
            customer.setOrderQuantity(customer.getOrderQuantity() + orderQuantity); // 团队单数
            customer.setOwnTotalBuy3(customer.getOwnTotalBuy3().add(totalAmount)); // 自己购买
            customerDao.update(customer);
            handleAccount2(customer.getId(), totalAmount, customer.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
            if (customer.getParentId() != null && customer.getParentId() != 1198 && customer.getLevelCopyId() != 11) {

                Customer cu1 = customerDao.queryById(customer.getParentId()); // 一层
                if (cu1 != null) {
                    cu1.setAchievement3(cu1.getAchievement3().add(totalAmount)); // 团队业绩
                    cu1.setOrderQuantity(cu1.getOrderQuantity() + orderQuantity); // 团队单数
                    customerDao.update(cu1);
                    handleAccount2(cu1.getId(), totalAmount, cu1.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                    if (cu1.getParentId() != null && cu1.getParentId() != 1198 && cu1.getLevelCopyId() != 11) {

                        Customer cu2 = customerDao.queryById(cu1.getParentId()); // 二层
                        if (cu2 != null) {
                            cu2.setAchievement3(cu2.getAchievement3().add(totalAmount));
                            cu2.setOrderQuantity(cu2.getOrderQuantity() + orderQuantity);
                            customerDao.update(cu2);
                            handleAccount2(cu2.getId(), totalAmount, cu2.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                            if (cu2.getParentId() != null && cu2.getParentId() != 1198 && cu2.getLevelCopyId() != 11) {

                                Customer cu3 = customerDao.queryById(cu2.getParentId()); // 三层
                                if (cu3 != null) {
                                    cu3.setAchievement3(cu3.getAchievement3().add(totalAmount));
                                    cu3.setOrderQuantity(cu3.getOrderQuantity() + orderQuantity);
                                    customerDao.update(cu3);
                                    handleAccount2(cu3.getId(), totalAmount, cu3.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                    if (cu3.getParentId() != null && cu3.getParentId() != 1198 && cu3.getLevelCopyId() != 11) {

                                        Customer cu4 = customerDao.queryById(cu3.getParentId()); // 四层
                                        if (cu4 != null) {
                                            cu4.setAchievement3(cu4.getAchievement3().add(totalAmount));
                                            cu4.setOrderQuantity(cu4.getOrderQuantity() + orderQuantity);
                                            customerDao.update(cu4);
                                            handleAccount2(cu4.getId(), totalAmount, cu4.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                            if (cu4.getParentId() != null && cu4.getParentId() != 1198 && cu4.getLevelCopyId() != 11) {

                                                Customer cu5 = customerDao.queryById(cu4.getParentId()); // 五层
                                                if (cu5 != null) {
                                                    cu5.setAchievement3(cu5.getAchievement3().add(totalAmount));
                                                    cu5.setOrderQuantity(cu5.getOrderQuantity() + orderQuantity);
                                                    customerDao.update(cu5);
                                                    handleAccount2(cu5.getId(), totalAmount, cu5.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                    if (cu5.getParentId() != null && cu5.getParentId() != 1198 && cu5.getLevelCopyId() != 11) {

                                                        Customer cu6 = customerDao.queryById(cu5.getParentId()); // 六层
                                                        if (cu6 != null) {
                                                            cu6.setAchievement3(cu6.getAchievement3().add(totalAmount));
                                                            cu6.setOrderQuantity(cu6.getOrderQuantity() + orderQuantity);
                                                            customerDao.update(cu6);
                                                            handleAccount2(cu6.getId(), totalAmount, cu6.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                            if (cu6.getParentId() != null && cu6.getParentId() != 1198 && cu6.getLevelCopyId() != 11) {

                                                                Customer cu7 = customerDao.queryById(cu6.getParentId()); // 七层
                                                                if (cu7 != null) {
                                                                    cu7.setAchievement3(cu7.getAchievement3().add(totalAmount));
                                                                    cu7.setOrderQuantity(cu7.getOrderQuantity() + orderQuantity);
                                                                    customerDao.update(cu7);
                                                                    handleAccount2(cu7.getId(), totalAmount, cu7.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                    if (cu7.getParentId() != null && cu7.getParentId() != 1198 && cu7.getLevelCopyId() != 11) {

                                                                        Customer cu8 = customerDao.queryById(cu7.getParentId()); // 八层
                                                                        if (cu8 != null) {
                                                                            cu8.setAchievement3(cu8.getAchievement3().add(totalAmount));
                                                                            cu8.setOrderQuantity(cu8.getOrderQuantity() + orderQuantity);
                                                                            customerDao.update(cu8);
                                                                            handleAccount2(cu8.getId(), totalAmount, cu8.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                            if (cu8.getParentId() != null && cu8.getParentId() != 1198 && cu8.getLevelCopyId() != 11) {

                                                                                Customer cu9 = customerDao.queryById(cu8.getParentId()); // 九层
                                                                                if (cu9 != null) {
                                                                                    cu9.setAchievement3(cu9.getAchievement3().add(totalAmount));
                                                                                    cu9.setOrderQuantity(cu9.getOrderQuantity() + orderQuantity);
                                                                                    customerDao.update(cu9);
                                                                                    handleAccount2(cu9.getId(), totalAmount, cu9.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                    if (cu9.getParentId() != null && cu9.getParentId() != 1198 && cu9.getLevelCopyId() != 11) {

                                                                                        Customer cu10 = customerDao.queryById(cu9.getParentId()); // 十层
                                                                                        if (cu10 != null) {
                                                                                            cu10.setAchievement3(cu10.getAchievement3().add(totalAmount));
                                                                                            cu10.setOrderQuantity(cu10.getOrderQuantity() + orderQuantity);
                                                                                            customerDao.update(cu10);
                                                                                            handleAccount2(cu10.getId(), totalAmount, cu10.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                            if (cu10.getParentId() != null && cu10.getParentId() != 1198 && cu10.getLevelCopyId() != 11) {

                                                                                                Customer cu11 = customerDao.queryById(cu10.getParentId()); // 十一层
                                                                                                if (cu11 != null) {
                                                                                                    cu11.setAchievement3(cu11.getAchievement3().add(totalAmount));
                                                                                                    cu11.setOrderQuantity(cu11.getOrderQuantity() + orderQuantity);
                                                                                                    customerDao.update(cu11);
                                                                                                    handleAccount2(cu11.getId(), totalAmount, cu11.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                    if (cu11.getParentId() != null && cu11.getParentId() != 1198 && cu11.getLevelCopyId() != 11) {

                                                                                                        Customer cu12 = customerDao.queryById(cu11.getParentId()); // 十二层
                                                                                                        if (cu12 != null) {
                                                                                                            cu12.setAchievement3(cu12.getAchievement3().add(totalAmount));
                                                                                                            cu12.setOrderQuantity(cu12.getOrderQuantity() + orderQuantity);
                                                                                                            customerDao.update(cu12);
                                                                                                            handleAccount2(cu12.getId(), totalAmount, cu12.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                            if (cu12.getParentId() != null && cu12.getParentId() != 1198 && cu12.getLevelCopyId() != 11) {

                                                                                                                Customer cu13 = customerDao.queryById(cu12.getParentId()); // 十三层
                                                                                                                if (cu13 != null) {
                                                                                                                    cu13.setAchievement3(cu13.getAchievement3().add(totalAmount));
                                                                                                                    cu13.setOrderQuantity(cu13.getOrderQuantity() + orderQuantity);
                                                                                                                    customerDao.update(cu13);
                                                                                                                    handleAccount2(cu13.getId(), totalAmount, cu13.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                    if (cu13.getParentId() != null && cu13.getParentId() != 1198 && cu13.getLevelCopyId() != 11) {

                                                                                                                        Customer cu14 = customerDao.queryById(cu13.getParentId()); // 十四层
                                                                                                                        if (cu14 != null) {
                                                                                                                            cu14.setAchievement3(cu14.getAchievement3().add(totalAmount));
                                                                                                                            cu14.setOrderQuantity(cu14.getOrderQuantity() + orderQuantity);
                                                                                                                            customerDao.update(cu14);
                                                                                                                            handleAccount2(cu14.getId(), totalAmount, cu14.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                            if (cu14.getParentId() != null && cu14.getParentId() != 1198 && cu14.getLevelCopyId() != 11) {

                                                                                                                                Customer cu15 = customerDao.queryById(cu14.getParentId()); // 十五层
                                                                                                                                if (cu15 != null) {
                                                                                                                                    cu15.setAchievement3(cu15.getAchievement3().add(totalAmount));
                                                                                                                                    cu15.setOrderQuantity(cu15.getOrderQuantity() + orderQuantity);
                                                                                                                                    customerDao.update(cu15);
                                                                                                                                    handleAccount2(cu15.getId(), totalAmount, cu15.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                    if (cu15.getParentId() != null && cu15.getParentId() != 1198 && cu15.getLevelCopyId() != 11) {

                                                                                                                                        Customer cu16 = customerDao.queryById(cu15.getParentId()); // 十六层
                                                                                                                                        if (cu16 != null) {
                                                                                                                                            cu16.setAchievement3(cu16.getAchievement3().add(totalAmount));
                                                                                                                                            cu16.setOrderQuantity(cu16.getOrderQuantity() + orderQuantity);
                                                                                                                                            customerDao.update(cu16);
                                                                                                                                            handleAccount2(cu16.getId(), totalAmount, cu16.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                            if (cu16.getParentId() != null && cu16.getParentId() != 1198 && cu16.getLevelCopyId() != 11) {

                                                                                                                                                Customer cu17 = customerDao.queryById(cu16.getParentId()); // 十七层
                                                                                                                                                if (cu17 != null) {
                                                                                                                                                    cu17.setAchievement3(cu17.getAchievement3().add(totalAmount));
                                                                                                                                                    cu17.setOrderQuantity(cu17.getOrderQuantity() + orderQuantity);
                                                                                                                                                    customerDao.update(cu17);
                                                                                                                                                    handleAccount2(cu17.getId(), totalAmount, cu17.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                    if (cu17.getParentId() != null && cu17.getParentId() != 1198 && cu17.getLevelCopyId() != 11) {

                                                                                                                                                        Customer cu18 = customerDao.queryById(cu17.getParentId()); // 十八层
                                                                                                                                                        if(cu18 != null){
                                                                                                                                                            cu18.setAchievement3(cu18.getAchievement3().add(totalAmount));
                                                                                                                                                            cu18.setOrderQuantity(cu18.getOrderQuantity() + orderQuantity);
                                                                                                                                                            customerDao.update(cu18);
                                                                                                                                                            handleAccount2(cu18.getId(), totalAmount, cu18.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                            if (cu18.getParentId() != null && cu18.getParentId() != 1198 && cu18.getLevelCopyId() != 11) {

                                                                                                                                                                Customer cu19 = customerDao.queryById(cu18.getParentId()); // 十九层
                                                                                                                                                                if(cu19 != null){
                                                                                                                                                                    cu19.setAchievement3(cu19.getAchievement3().add(totalAmount));
                                                                                                                                                                    cu19.setOrderQuantity(cu19.getOrderQuantity() + orderQuantity);
                                                                                                                                                                    customerDao.update(cu19);
                                                                                                                                                                    handleAccount2(cu19.getId(), totalAmount, cu19.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                    if (cu19.getParentId() != null && cu19.getParentId() != 1198 && cu19.getLevelCopyId() != 11) {

                                                                                                                                                                        Customer cu20 = customerDao.queryById(cu19.getParentId()); // 二十层
                                                                                                                                                                        if(cu20 != null){
                                                                                                                                                                            cu20.setAchievement3(cu20.getAchievement3().add(totalAmount));
                                                                                                                                                                            cu20.setOrderQuantity(cu20.getOrderQuantity() + orderQuantity);
                                                                                                                                                                            customerDao.update(cu20);
                                                                                                                                                                            handleAccount2(cu20.getId(), totalAmount, cu20.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                            if (cu20.getParentId() != null && cu20.getParentId() != 1198 && cu20.getLevelCopyId() != 11) {

                                                                                                                                                                                Customer cu21 = customerDao.queryById(cu20.getParentId()); // 二十一层
                                                                                                                                                                                if(cu21 != null){
                                                                                                                                                                                    cu21.setAchievement3(cu21.getAchievement3().add(totalAmount));
                                                                                                                                                                                    cu21.setOrderQuantity(cu21.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                    customerDao.update(cu21);
                                                                                                                                                                                    handleAccount2(cu21.getId(), totalAmount, cu21.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                                    if (cu21.getParentId() != null && cu21.getParentId() != 1198 && cu21.getLevelCopyId() != 11) {

                                                                                                                                                                                        Customer cu22 = customerDao.queryById(cu21.getParentId()); // 二十二层
                                                                                                                                                                                        if(cu22 != null){
                                                                                                                                                                                            cu22.setAchievement3(cu22.getAchievement3().add(totalAmount));
                                                                                                                                                                                            cu22.setOrderQuantity(cu22.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                            customerDao.update(cu22);
                                                                                                                                                                                            handleAccount2(cu22.getId(), totalAmount, cu22.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                                            if (cu22.getParentId() != null && cu22.getParentId() != 1198 && cu22.getLevelCopyId() != 11) {

                                                                                                                                                                                                Customer cu23 = customerDao.queryById(cu22.getParentId()); // 二十三层
                                                                                                                                                                                                if(cu23 != null){
                                                                                                                                                                                                    cu23.setAchievement3(cu23.getAchievement3().add(totalAmount));
                                                                                                                                                                                                    cu23.setOrderQuantity(cu23.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                    customerDao.update(cu23);
                                                                                                                                                                                                    handleAccount2(cu23.getId(), totalAmount, cu23.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                                                    if (cu23.getParentId() != null && cu23.getParentId() != 1198 && cu23.getLevelCopyId() != 11) {

                                                                                                                                                                                                        Customer cu24 = customerDao.queryById(cu23.getParentId()); // 二十四层
                                                                                                                                                                                                        if(cu24 != null){
                                                                                                                                                                                                            cu24.setAchievement3(cu24.getAchievement3().add(totalAmount));
                                                                                                                                                                                                            cu24.setOrderQuantity(cu24.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                            customerDao.update(cu24);
                                                                                                                                                                                                            handleAccount2(cu24.getId(), totalAmount, cu24.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                                                            if (cu24.getParentId() != null && cu24.getParentId() != 1198 && cu24.getLevelCopyId() != 11) {

                                                                                                                                                                                                                Customer cu25 = customerDao.queryById(cu24.getParentId()); // 二十五层
                                                                                                                                                                                                                if(cu25 != null){
                                                                                                                                                                                                                    cu25.setAchievement3(cu25.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                    cu25.setOrderQuantity(cu25.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                    customerDao.update(cu25);
                                                                                                                                                                                                                    handleAccount2(cu25.getId(), totalAmount, cu25.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());

                                                                                                                                                                                                                    if (cu25.getParentId() != null && cu25.getParentId() != 1198 && cu25.getLevelCopyId() != 11) {

                                                                                                                                                                                                                        Customer cu26 = customerDao.queryById(cu25.getParentId()); // 二十六层
                                                                                                                                                                                                                        if(cu26 != null){
                                                                                                                                                                                                                            cu26.setAchievement3(cu26.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                            cu26.setOrderQuantity(cu26.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                            customerDao.update(cu26);
                                                                                                                                                                                                                            handleAccount2(cu26.getId(), totalAmount, cu26.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());

                                                                                                                                                                                                                            if (cu26.getParentId() != null && cu26.getParentId() != 1198 && cu26.getLevelCopyId() != 11) {

                                                                                                                                                                                                                                Customer cu27 = customerDao.queryById(cu26.getParentId()); // 二十七层
                                                                                                                                                                                                                                if(cu27 != null){
                                                                                                                                                                                                                                    cu27.setAchievement3(cu27.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                                    cu27.setOrderQuantity(cu27.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                                    customerDao.update(cu27);
                                                                                                                                                                                                                                    handleAccount2(cu27.getId(), totalAmount, cu27.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());

                                                                                                                                                                                                                                    if (cu27.getParentId() != null && cu27.getParentId() != 1198 && cu27.getLevelCopyId() != 11) {

                                                                                                                                                                                                                                        Customer cu28 = customerDao.queryById(cu27.getParentId()); // 二十八层
                                                                                                                                                                                                                                        if(cu28 != null){
                                                                                                                                                                                                                                            cu28.setAchievement3(cu28.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                                            cu28.setOrderQuantity(cu28.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                                            customerDao.update(cu28);
                                                                                                                                                                                                                                            handleAccount2(cu28.getId(), totalAmount, cu28.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());

                                                                                                                                                                                                                                            if (cu28.getParentId() != null && cu28.getParentId() != 1198 && cu28.getLevelCopyId() != 11) {

                                                                                                                                                                                                                                                Customer cu29 = customerDao.queryById(cu28.getParentId()); // 二十九层
                                                                                                                                                                                                                                                if(cu29 != null){
                                                                                                                                                                                                                                                    cu29.setAchievement3(cu29.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                                                    cu29.setOrderQuantity(cu29.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                                                    customerDao.update(cu29);
                                                                                                                                                                                                                                                    handleAccount2(cu29.getId(), totalAmount, cu29.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());

                                                                                                                                                                                                                                                    if (cu29.getParentId() != null && cu29.getParentId() != 1198 && cu29.getLevelCopyId() != 11) {

                                                                                                                                                                                                                                                        Customer cu30 = customerDao.queryById(cu29.getParentId()); // 三十层
                                                                                                                                                                                                                                                        if(cu30 != null){
                                                                                                                                                                                                                                                            cu30.setAchievement3(cu30.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                                                            cu30.setOrderQuantity(cu30.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                                                            customerDao.update(cu30);
                                                                                                                                                                                                                                                            handleAccount2(cu30.getId(), totalAmount, cu30.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());

                                                                                                                                                                                                                                                            if (cu30.getParentId() != null && cu30.getParentId() != 1198 && cu30.getLevelCopyId() != 11) {

                                                                                                                                                                                                                                                                Customer cu31 = customerDao.queryById(cu30.getParentId()); // 三十一层
                                                                                                                                                                                                                                                                if(cu31 != null){
                                                                                                                                                                                                                                                                    cu31.setAchievement3(cu31.getAchievement3().add(totalAmount));
                                                                                                                                                                                                                                                                    cu31.setOrderQuantity(cu31.getOrderQuantity() + orderQuantity);
                                                                                                                                                                                                                                                                    customerDao.update(cu31);
                                                                                                                                                                                                                                                                    handleAccount2(cu31.getId(), totalAmount, cu31.getAchievement3(), orders.getOrderNo(), customer.getAgentCode());
                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                    }
                                                                                                                                                                                                                                }
                                                                                                                                                                                                                            }
                                                                                                                                                                                                                        }
                                                                                                                                                                                                                    }
                                                                                                                                                                                                                }
                                                                                                                                                                                                            }
                                                                                                                                                                                                        }
                                                                                                                                                                                                    }
                                                                                                                                                                                                }
                                                                                                                                                                                            }
                                                                                                                                                                                        }
                                                                                                                                                                                    }
                                                                                                                                                                                }
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }
                                                                                                                                                            }
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                                }
                                                                                                                                            }
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }


    /**
     * 共享模式 分润
     * @param customer
     * @param orders
     */
    public void shareSplitProfit(Customer customer, Orders orders){
        // 分润
        Integer quantity = 0;
        if(orders.getTotalAmount().doubleValue() >= 369 && orders.getTotalAmount().doubleValue() < 3690){
            quantity = 1;
        }else if(orders.getTotalAmount().doubleValue() >= 3690 && orders.getTotalAmount().doubleValue() < 36900){
            quantity = 10;
        }else if(orders.getTotalAmount().doubleValue() >= 36900){
            quantity = 100;
        }
        // V等级分润
        if(customer.getParentId() != null && customer.getParentId() != 1198){
            Customer cu1 = customerDao.queryById(customer.getParentId());
            if(cu1 != null){
                Integer orderLevel = customer.getLevelCopy4Id();
                // 下单人等级 小于 上级
                if(orderLevel < cu1.getLevelCopy4Id()){
                    // 直接分钱
                    if(cu1.getLevelCopy4Id() == 2){
                        BigDecimal bd = new BigDecimal(15);
                        handleAccount1(cu1.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        // 找一个就近为2的
                        Customer nearby2 = findCustomer_nearby(cu1, 2);
                        if(nearby2 != null){
                            handleAccount1(nearby2.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                        // 继续找大于2的
                        Customer cu2 = findParentUser_nearby(cu1, 2);
                        if(cu2 != null){
                            if(cu2.getLevelCopy4Id() == 3){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为3的
                                Customer nearby3 = findCustomer_nearby(cu2, 3);
                                if(nearby3 != null){
                                    handleAccount1(nearby3.getId(), BigDecimal.valueOf(15 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于3的
                                Customer cu3 = findParentUser_nearby(cu2, 3);
                                if(cu3 != null){
                                    if(cu3.getLevelCopy4Id() == 4){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为4的
                                        Customer nearby4 = findCustomer_nearby(cu3, 4);
                                        if(nearby4 != null){
                                            handleAccount1(nearby4.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于4的
                                        Customer cu4 = findParentUser_nearby(cu3, 4);
                                        if(cu4 != null){
                                            if(cu4.getLevelCopy4Id() == 5){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为5的
                                                Customer nearby5 = findCustomer_nearby(cu4, 5);
                                                if(nearby5 != null){
                                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于5的
                                                Customer cu5 = findParentUser_nearby(cu4, 5);
                                                if(cu5 != null){
                                                    if(cu5.getLevelCopy4Id() == 6){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为6的
                                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                        if(nearby6 != null){
                                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于6的
                                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                                        if(cu6 != null){
                                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            // 找一个就近为7的
                                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                            if(nearby7 != null){
                                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            }
                                                        }
                                                    }else if(cu5.getLevelCopy4Id() == 7){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为7的
                                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                        if(nearby7 != null){
                                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 6){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu4, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu4, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 7){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu4, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 5){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(26), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu3, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(26 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu3, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 6){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(37), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu3, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(37 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu3, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 7){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(48), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu3, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(48 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 4){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(30), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为4的
                                Customer nearby4 = findCustomer_nearby(cu2, 4);
                                if(nearby4 != null){
                                    handleAccount1(nearby4.getId(), BigDecimal.valueOf(30 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于4的
                                Customer cu4 = findParentUser_nearby(cu2, 4);
                                if(cu4 != null){
                                    if(cu4.getLevelCopy4Id() == 5){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu4, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu4, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 6){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu4, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu4, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 7){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu4, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 5){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(41), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu2, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(41 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu2, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 6){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(52), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu2, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(52 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu2, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 7){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(63), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu2, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(63 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(cu1.getLevelCopy4Id() == 3){
                        BigDecimal bd = new BigDecimal(30);
                        //if(orderLevel == 2){
                        //bd = new BigDecimal(15);
                        //}
                        handleAccount1(cu1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                        // 找一个就近为3的
                        Customer nearby3 = findCustomer_nearby(cu1, 3);
                        if(nearby3 != null){
                            handleAccount1(nearby3.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                        // 继续找大于3的
                        Customer cu3 = findParentUser_nearby(cu1, 3);
                        if(cu3 != null){
                            if(cu3.getLevelCopy4Id() == 4){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为4的
                                Customer nearby4 = findCustomer_nearby(cu3, 4);
                                if(nearby4 != null){
                                    handleAccount1(nearby4.getId(), BigDecimal.valueOf(15 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于4的
                                Customer cu4 = findParentUser_nearby(cu3, 4);
                                if(cu4 != null){
                                    if(cu4.getLevelCopy4Id() == 5){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu4, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu4, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 6){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu4, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu4, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 7){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu4, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu3.getLevelCopy4Id() == 5){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(26), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu3, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu3, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu3.getLevelCopy4Id() == 6){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(37), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu3, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(37 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu3, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu3.getLevelCopy4Id() == 7){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(48), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu3, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(48 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(cu1.getLevelCopy4Id() == 4){
                        BigDecimal bd = new BigDecimal(45);
                        //if(orderLevel == 2){
                        //bd = new BigDecimal(30);
                        //}else if(orderLevel == 3){
                        //bd = new BigDecimal(15);
                        //}
                        handleAccount1(cu1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                        // 找一个就近为4的
                        Customer nearby4 = findCustomer_nearby(cu1, 4);
                        if(nearby4 != null){
                            handleAccount1(nearby4.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                        // 继续找大于4的
                        Customer cu4 = findParentUser_nearby(cu1, 4);
                        if(cu4 != null){
                            if(cu4.getLevelCopy4Id() == 5){
                                handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu4, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu4, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu4.getLevelCopy4Id() == 6){
                                handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu4, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu4, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu4.getLevelCopy4Id() == 7){
                                handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu4, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(cu1.getLevelCopy4Id() == 5){
                        BigDecimal bd = new BigDecimal(56);
                        //if(orderLevel == 2){
                        //bd = new BigDecimal(41);
                        //}else if(orderLevel == 3){
                        //bd = new BigDecimal(26);
                        //}else if(orderLevel == 4){
                        //bd = new BigDecimal(11);
                        //}
                        handleAccount1(cu1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                        // 找一个就近为5的
                        Customer nearby5 = findCustomer_nearby(cu1, 5);
                        if(nearby5 != null){
                            handleAccount1(nearby5.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                        // 继续找大于5的
                        Customer cu5 = findParentUser_nearby(cu1, 5);
                        if(cu5 != null){
                            if(cu5.getLevelCopy4Id() == 6){
                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu5.getLevelCopy4Id() == 7){
                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(cu1.getLevelCopy4Id() == 6){
                        BigDecimal bd = new BigDecimal(67);
                        //if(orderLevel == 2){
                        //bd = new BigDecimal(52);
                        //}else if(orderLevel == 3){
                        //bd = new BigDecimal(37);
                        //}else if(orderLevel == 4){
                        //bd = new BigDecimal(22);
                        //}else if(orderLevel == 5){
                        //bd = new BigDecimal(11);
                        //}
                        handleAccount1(cu1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                        // 找一个就近为6的
                        Customer nearby6 = findCustomer_nearby(cu1, 6);
                        if(nearby6 != null){
                            handleAccount1(nearby6.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                        // 继续找大于6的
                        Customer cu6 = findParentUser_nearby(cu1, 6);
                        if(cu6 != null){
                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                            // 找一个就近为7的
                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                            if(nearby7 != null){
                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                            }
                        }
                    }else if(cu1.getLevelCopy4Id() == 7){
                        BigDecimal bd = new BigDecimal(78);
                        //if(orderLevel == 2){
                        //bd = new BigDecimal(63);
                        //}else if(orderLevel == 3){
                        //bd = new BigDecimal(48);
                        //}else if(orderLevel == 4){
                        //bd = new BigDecimal(33);
                        //}else if(orderLevel == 5){
                        //bd = new BigDecimal(22);
                        //}else if(orderLevel == 6){
                        //bd = new BigDecimal(11);
                        //}
                        handleAccount1(cu1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                        // 找一个就近为7的
                        Customer nearby7 = findCustomer_nearby(cu1, 7);
                        if(nearby7 != null){
                            handleAccount1(nearby7.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                    }
                }
                // 下单人等级 大于等于 上级
                else if(orderLevel >= cu1.getLevelCopy4Id()){
                    if(orderLevel == 1){
                        // 继续找大于1的
                        Customer cu1_1 = findParentUser_nearby(customer, 1);
                        if(cu1_1 != null){
                            if(cu1_1.getLevelCopy4Id() == 2){
                                BigDecimal bd = new BigDecimal(15);
                                handleAccount1(cu1_1.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为2的
                                Customer nearby2 = findCustomer_nearby(cu1_1, 2);
                                if(nearby2 != null){
                                    handleAccount1(nearby2.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于2的
                                Customer cu2 = findParentUser_nearby(cu1_1, 2);
                                if(cu2 != null){
                                    if(cu2.getLevelCopy4Id() == 3){
                                        handleAccount1(cu2.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为3的
                                        Customer nearby3 = findCustomer_nearby(cu2, 3);
                                        if(nearby3 != null){
                                            handleAccount1(nearby3.getId(), BigDecimal.valueOf(15 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于3的
                                        Customer cu3 = findParentUser_nearby(cu2, 3);
                                        if(cu3 != null){
                                            if(cu3.getLevelCopy4Id() == 4){
                                                handleAccount1(cu3.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为4的
                                                Customer nearby4 = findCustomer_nearby(cu3, 4);
                                                if(nearby4 != null){
                                                    handleAccount1(nearby4.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于4的
                                                Customer cu4 = findParentUser_nearby(cu3, 4);
                                                if(cu4 != null){
                                                    if(cu4.getLevelCopy4Id() == 5){
                                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为5的
                                                        Customer nearby5 = findCustomer_nearby(cu4, 5);
                                                        if(nearby5 != null){
                                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于5的
                                                        Customer cu5 = findParentUser_nearby(cu4, 5);
                                                        if(cu5 != null){
                                                            if(cu5.getLevelCopy4Id() == 6){
                                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                                // 找一个就近为6的
                                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                                if(nearby6 != null){
                                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                                }
                                                                // 继续找大于6的
                                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                                if(cu6 != null){
                                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                                    // 找一个就近为7的
                                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                                    if(nearby7 != null){
                                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                                    }
                                                                }
                                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                                // 找一个就近为7的
                                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                                if(nearby7 != null){
                                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                                }
                                                            }
                                                        }
                                                    }else if(cu4.getLevelCopy4Id() == 6){
                                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为6的
                                                        Customer nearby6 = findCustomer_nearby(cu4, 6);
                                                        if(nearby6 != null){
                                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于6的
                                                        Customer cu6 = findParentUser_nearby(cu4, 6);
                                                        if(cu6 != null){
                                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            // 找一个就近为7的
                                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                            if(nearby7 != null){
                                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            }
                                                        }
                                                    }else if(cu4.getLevelCopy4Id() == 7){
                                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为7的
                                                        Customer nearby7 = findCustomer_nearby(cu4, 7);
                                                        if(nearby7 != null){
                                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                    }
                                                }
                                            }else if(cu3.getLevelCopy4Id() == 5){
                                                handleAccount1(cu3.getId(), BigDecimal.valueOf(26), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为5的
                                                Customer nearby5 = findCustomer_nearby(cu3, 5);
                                                if(nearby5 != null){
                                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(26 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于5的
                                                Customer cu5 = findParentUser_nearby(cu3, 5);
                                                if(cu5 != null){
                                                    if(cu5.getLevelCopy4Id() == 6){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为6的
                                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                        if(nearby6 != null){
                                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于6的
                                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                                        if(cu6 != null){
                                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            // 找一个就近为7的
                                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                            if(nearby7 != null){
                                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            }
                                                        }
                                                    }else if(cu5.getLevelCopy4Id() == 7){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为7的
                                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                        if(nearby7 != null){
                                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                    }
                                                }
                                            }else if(cu3.getLevelCopy4Id() == 6){
                                                handleAccount1(cu3.getId(), BigDecimal.valueOf(37), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu3, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(37 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu3, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu3.getLevelCopy4Id() == 7){
                                                handleAccount1(cu3.getId(), BigDecimal.valueOf(48), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu3, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(48 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu2.getLevelCopy4Id() == 4){
                                        handleAccount1(cu2.getId(), BigDecimal.valueOf(30), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为4的
                                        Customer nearby4 = findCustomer_nearby(cu2, 4);
                                        if(nearby4 != null){
                                            handleAccount1(nearby4.getId(), BigDecimal.valueOf(30 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于4的
                                        Customer cu4 = findParentUser_nearby(cu2, 4);
                                        if(cu4 != null){
                                            if(cu4.getLevelCopy4Id() == 5){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为5的
                                                Customer nearby5 = findCustomer_nearby(cu4, 5);
                                                if(nearby5 != null){
                                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于5的
                                                Customer cu5 = findParentUser_nearby(cu4, 5);
                                                if(cu5 != null){
                                                    if(cu5.getLevelCopy4Id() == 6){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为6的
                                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                        if(nearby6 != null){
                                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于6的
                                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                                        if(cu6 != null){
                                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            // 找一个就近为7的
                                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                            if(nearby7 != null){
                                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            }
                                                        }
                                                    }else if(cu5.getLevelCopy4Id() == 7){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为7的
                                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                        if(nearby7 != null){
                                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 6){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu4, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu4, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 7){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu4, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu2.getLevelCopy4Id() == 5){
                                        handleAccount1(cu2.getId(), BigDecimal.valueOf(41), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu2, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(41 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu2, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu2.getLevelCopy4Id() == 6){
                                        handleAccount1(cu2.getId(), BigDecimal.valueOf(52), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu2, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(52 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu2, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu2.getLevelCopy4Id() == 7){
                                        handleAccount1(cu2.getId(), BigDecimal.valueOf(63), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu2, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(63 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu1_1.getLevelCopy4Id() == 3){
                                BigDecimal bd = new BigDecimal(30);
                                //if(orderLevel == 2){
                                //bd = new BigDecimal(15);
                                //}
                                handleAccount1(cu1_1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为3的
                                Customer nearby3 = findCustomer_nearby(cu1_1, 3);
                                if(nearby3 != null){
                                    handleAccount1(nearby3.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于3的
                                Customer cu3 = findParentUser_nearby(cu1_1, 3);
                                if(cu3 != null){
                                    if(cu3.getLevelCopy4Id() == 4){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为4的
                                        Customer nearby4 = findCustomer_nearby(cu3, 4);
                                        if(nearby4 != null){
                                            handleAccount1(nearby4.getId(), BigDecimal.valueOf(15 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于4的
                                        Customer cu4 = findParentUser_nearby(cu3, 4);
                                        if(cu4 != null){
                                            if(cu4.getLevelCopy4Id() == 5){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为5的
                                                Customer nearby5 = findCustomer_nearby(cu4, 5);
                                                if(nearby5 != null){
                                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于5的
                                                Customer cu5 = findParentUser_nearby(cu4, 5);
                                                if(cu5 != null){
                                                    if(cu5.getLevelCopy4Id() == 6){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为6的
                                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                        if(nearby6 != null){
                                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于6的
                                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                                        if(cu6 != null){
                                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            // 找一个就近为7的
                                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                            if(nearby7 != null){
                                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            }
                                                        }
                                                    }else if(cu5.getLevelCopy4Id() == 7){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为7的
                                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                        if(nearby7 != null){
                                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 6){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu4, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu4, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 7){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu4, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 5){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(26), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu3, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu3, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 6){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(37), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu3, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(37 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu3, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 7){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(48), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu3, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(48 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu1_1.getLevelCopy4Id() == 4){
                                BigDecimal bd = new BigDecimal(45);
                                //if(orderLevel == 2){
                                //bd = new BigDecimal(30);
                                //}else if(orderLevel == 3){
                                //bd = new BigDecimal(15);
                                //}
                                handleAccount1(cu1_1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为4的
                                Customer nearby4 = findCustomer_nearby(cu1_1, 4);
                                if(nearby4 != null){
                                    handleAccount1(nearby4.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于4的
                                Customer cu4 = findParentUser_nearby(cu1_1, 4);
                                if(cu4 != null){
                                    if(cu4.getLevelCopy4Id() == 5){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu4, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu4, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 6){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu4, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu4, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 7){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu4, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu1_1.getLevelCopy4Id() == 5){
                                BigDecimal bd = new BigDecimal(56);
                                //if(orderLevel == 2){
                                //bd = new BigDecimal(41);
                                //}else if(orderLevel == 3){
                                //bd = new BigDecimal(26);
                                //}else if(orderLevel == 4){
                                //bd = new BigDecimal(11);
                                //}
                                handleAccount1(cu1_1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu1_1, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu1_1, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu1_1.getLevelCopy4Id() == 6){
                                BigDecimal bd = new BigDecimal(67);
                                //if(orderLevel == 2){
                                //bd = new BigDecimal(52);
                                //}else if(orderLevel == 3){
                                //bd = new BigDecimal(37);
                                //}else if(orderLevel == 4){
                                //bd = new BigDecimal(22);
                                //}else if(orderLevel == 5){
                                //bd = new BigDecimal(11);
                                //}
                                handleAccount1(cu1_1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu1_1, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu1_1, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu1_1.getLevelCopy4Id() == 7){
                                BigDecimal bd = new BigDecimal(78);
                                //if(orderLevel == 2){
                                //bd = new BigDecimal(63);
                                //}else if(orderLevel == 3){
                                //bd = new BigDecimal(48);
                                //}else if(orderLevel == 4){
                                //bd = new BigDecimal(33);
                                //}else if(orderLevel == 5){
                                //bd = new BigDecimal(22);
                                //}else if(orderLevel == 6){
                                //bd = new BigDecimal(11);
                                //}
                                handleAccount1(cu1_1.getId(), bd, orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu1_1, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), bd.multiply(BigDecimal.valueOf(0.2)), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(orderLevel == 2){
                        // 继续找大于2的
                        Customer cu2 = findParentUser_nearby(customer, 2);
                        if(cu2 != null){
                            if(cu2.getLevelCopy4Id() == 3){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为3的
                                Customer nearby3 = findCustomer_nearby(cu2, 3);
                                if(nearby3 != null){
                                    handleAccount1(nearby3.getId(), BigDecimal.valueOf(15 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于3的
                                Customer cu3 = findParentUser_nearby(cu2, 3);
                                if(cu3 != null){
                                    if(cu3.getLevelCopy4Id() == 4){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为4的
                                        Customer nearby4 = findCustomer_nearby(cu3, 4);
                                        if(nearby4 != null){
                                            handleAccount1(nearby4.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于4的
                                        Customer cu4 = findParentUser_nearby(cu3, 4);
                                        if(cu4 != null){
                                            if(cu4.getLevelCopy4Id() == 5){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为5的
                                                Customer nearby5 = findCustomer_nearby(cu4, 5);
                                                if(nearby5 != null){
                                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于5的
                                                Customer cu5 = findParentUser_nearby(cu4, 5);
                                                if(cu5 != null){
                                                    if(cu5.getLevelCopy4Id() == 6){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为6的
                                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                        if(nearby6 != null){
                                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                        // 继续找大于6的
                                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                                        if(cu6 != null){
                                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            // 找一个就近为7的
                                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                            if(nearby7 != null){
                                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                            }
                                                        }
                                                    }else if(cu5.getLevelCopy4Id() == 7){
                                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        // 找一个就近为7的
                                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                        if(nearby7 != null){
                                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                        }
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 6){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu4, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu4, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu4.getLevelCopy4Id() == 7){
                                                handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu4, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 5){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(26), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu3, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(26 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu3, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 6){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(37), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu3, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(37 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu3, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu3.getLevelCopy4Id() == 7){
                                        handleAccount1(cu3.getId(), BigDecimal.valueOf(48), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu3, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(48 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 4){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(30), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为4的
                                Customer nearby4 = findCustomer_nearby(cu2, 4);
                                if(nearby4 != null){
                                    handleAccount1(nearby4.getId(), BigDecimal.valueOf(30 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于4的
                                Customer cu4 = findParentUser_nearby(cu2, 4);
                                if(cu4 != null){
                                    if(cu4.getLevelCopy4Id() == 5){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu4, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu4, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 6){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu4, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu4, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 7){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu4, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 5){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(41), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu2, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(41 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu2, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 6){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(52), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu2, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(52 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu2, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu2.getLevelCopy4Id() == 7){
                                handleAccount1(cu2.getId(), BigDecimal.valueOf(63), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu2, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(63 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(orderLevel == 3){
                        // 继续找大于3的
                        Customer cu3 = findParentUser_nearby(customer, 3);
                        if(cu3 != null){
                            if(cu3.getLevelCopy4Id() == 4){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(15), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为4的
                                Customer nearby4 = findCustomer_nearby(cu3, 4);
                                if(nearby4 != null){
                                    handleAccount1(nearby4.getId(), BigDecimal.valueOf(15 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于4的
                                Customer cu4 = findParentUser_nearby(cu3, 4);
                                if(cu4 != null){
                                    if(cu4.getLevelCopy4Id() == 5){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为5的
                                        Customer nearby5 = findCustomer_nearby(cu4, 5);
                                        if(nearby5 != null){
                                            handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于5的
                                        Customer cu5 = findParentUser_nearby(cu4, 5);
                                        if(cu5 != null){
                                            if(cu5.getLevelCopy4Id() == 6){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为6的
                                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                                if(nearby6 != null){
                                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                                // 继续找大于6的
                                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                                if(cu6 != null){
                                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    // 找一个就近为7的
                                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                                    if(nearby7 != null){
                                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                    }
                                                }
                                            }else if(cu5.getLevelCopy4Id() == 7){
                                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                // 找一个就近为7的
                                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                                if(nearby7 != null){
                                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                                }
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 6){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu4, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu4, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu4.getLevelCopy4Id() == 7){
                                        handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu4, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu3.getLevelCopy4Id() == 5){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(26), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu3, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu3, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu3.getLevelCopy4Id() == 6){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(37), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu3, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(37 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu3, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu3.getLevelCopy4Id() == 7){
                                handleAccount1(cu3.getId(), BigDecimal.valueOf(48), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu3, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(48 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(orderLevel == 4){
                        // 继续找大于4的
                        Customer cu4 = findParentUser_nearby(customer, 4);
                        if(cu4 != null){
                            if(cu4.getLevelCopy4Id() == 5){
                                handleAccount1(cu4.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为5的
                                Customer nearby5 = findCustomer_nearby(cu4, 5);
                                if(nearby5 != null){
                                    handleAccount1(nearby5.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于5的
                                Customer cu5 = findParentUser_nearby(cu4, 5);
                                if(cu5 != null){
                                    if(cu5.getLevelCopy4Id() == 6){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为6的
                                        Customer nearby6 = findCustomer_nearby(cu5, 6);
                                        if(nearby6 != null){
                                            handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                        // 继续找大于6的
                                        Customer cu6 = findParentUser_nearby(cu5, 6);
                                        if(cu6 != null){
                                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            // 找一个就近为7的
                                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                                            if(nearby7 != null){
                                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                            }
                                        }
                                    }else if(cu5.getLevelCopy4Id() == 7){
                                        handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        // 找一个就近为7的
                                        Customer nearby7 = findCustomer_nearby(cu5, 7);
                                        if(nearby7 != null){
                                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                        }
                                    }
                                }
                            }else if(cu4.getLevelCopy4Id() == 6){
                                handleAccount1(cu4.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu4, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu4, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu4.getLevelCopy4Id() == 7){
                                handleAccount1(cu4.getId(), BigDecimal.valueOf(33), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu4, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(33 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(orderLevel == 5){
                        // 继续找大于5的
                        Customer cu5 = findParentUser_nearby(customer, 5);
                        if(cu5 != null){
                            if(cu5.getLevelCopy4Id() == 6){
                                handleAccount1(cu5.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为6的
                                Customer nearby6 = findCustomer_nearby(cu5, 6);
                                if(nearby6 != null){
                                    handleAccount1(nearby6.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                                // 继续找大于6的
                                Customer cu6 = findParentUser_nearby(cu5, 6);
                                if(cu6 != null){
                                    handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    // 找一个就近为7的
                                    Customer nearby7 = findCustomer_nearby(cu6, 7);
                                    if(nearby7 != null){
                                        handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                    }
                                }
                            }else if(cu5.getLevelCopy4Id() == 7){
                                handleAccount1(cu5.getId(), BigDecimal.valueOf(22), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                // 找一个就近为7的
                                Customer nearby7 = findCustomer_nearby(cu5, 7);
                                if(nearby7 != null){
                                    handleAccount1(nearby7.getId(), BigDecimal.valueOf(22 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                                }
                            }
                        }
                    }else if(orderLevel == 6){
                        // 继续找大于6的
                        Customer cu6 = findParentUser_nearby(customer, 6);
                        if(cu6 != null){
                            handleAccount1(cu6.getId(), BigDecimal.valueOf(11), orders.getOrderNo(), customer.getAgentCode(), quantity);
                            // 找一个就近为7的
                            Customer nearby7 = findCustomer_nearby(cu6, 7);
                            if(nearby7 != null){
                                handleAccount1(nearby7.getId(), BigDecimal.valueOf(11 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                            }
                        }
                    }else if(orderLevel == 7){
                        // 找一个就近为7的
                        Customer nearby7 = findCustomer_nearby(customer, 7);
                        if(nearby7 != null){
                            handleAccount1(nearby7.getId(), BigDecimal.valueOf(78 * 0.2), orders.getOrderNo(), customer.getAgentCode(), quantity);
                        }
                    }
                }
            }
        }
    }


    /**
     * 获取就近高等级
     * @param customer
     * @param levelCopy4Id
     * @return
     */
    public Customer findParentUser_nearby(Customer customer, Integer levelCopy4Id){
        Integer newId = 0;
        if (customer.getParentId() != null && customer.getParentId() != 1198 && customer.getLevelCopy4Id() != 8) {
            newId = customer.getParentId();
        }
        Customer newCustomer = customerDao.queryById(newId);
        if(newCustomer == null){
            return newCustomer;
        }
        if (newCustomer.getLevelCopy4Id() > levelCopy4Id) {
            return newCustomer;
        } else {
            while (newCustomer.getLevelCopy4Id() <= levelCopy4Id) {
                newCustomer = customerDao.queryById(newId);
                if(newCustomer == null){
                    break;
                }
                if (newCustomer.getLevelCopy4Id() > levelCopy4Id) {
                    break;
                } else {
                    if (newCustomer.getParentId() != null && newCustomer.getParentId() != 1198 && newCustomer.getLevelCopy4Id() != 8) {
                        newId = newCustomer.getParentId();
                    }else{
                        break;
                    }
                }
            }
        }
        return newCustomer;
    }


    /**
     * 获取就近同等级
     * @param customer
     * @param levelCopy4Id
     * @return
     */
    public Customer findCustomer_nearby(Customer customer, Integer levelCopy4Id){
        Integer newId = 0;
        if (customer.getParentId() != null && customer.getParentId() != 1198 && customer.getLevelCopy4Id() != 8) {
            newId = customer.getParentId();
        }
        Customer newCustomer = customerDao.queryById(newId);
        if(newCustomer == null){
            return newCustomer;
        }
        if (newCustomer.getLevelCopy4Id() == levelCopy4Id) {
            return newCustomer;
        } else {
            while (newCustomer.getLevelCopy4Id() != levelCopy4Id) {
                newCustomer = customerDao.queryById(newId);
                if(newCustomer == null){
                    break;
                }
                if(newId == 1 || newCustomer.getLevelCopy4Id() == 8){
                    return null;
                }
                if (newCustomer.getLevelCopy4Id() == levelCopy4Id) {
                    break;
                } else {
                    if (newCustomer.getParentId() != null && newCustomer.getParentId() != 1198 && newCustomer.getLevelCopy4Id() != 8) {
                        newId = newCustomer.getParentId();
                    }else{
                        break;
                    }
                }
            }
        }
        return newCustomer;
    }


    /**
     * 共享模式 - 增加业绩记录
     * @param userId
     * @param bd
     * @param orderNo
     * @param agentCode
     */
    public void handleAccount2(Integer userId, BigDecimal amount, BigDecimal bd, String orderNo, String agentCode){
        AccountRecord ar1 = new AccountRecord();
        ar1.setIntoUserId(userId);
        ar1.setUpdateTime(new Date());
        ar1.setType("4");
        ar1.setAmount(amount);
        ar1.setNowAmount(bd);
        ar1.setSign("1");
        ar1.setOrderNo(orderNo);
        ar1.setInfo(agentCode + "购买成功! 您的业绩增加：" + amount);
        accountRecordDao.save(ar1);
    }


    /**
     * 共享模式 - 增加共享余额记录
     * @param userId
     * @param amount
     * @param orderNo
     * @param agentCode
     * @param quantity
     */
    public void handleAccount1(Integer userId, BigDecimal amount, String orderNo, String agentCode, Integer quantity){
        Account account = accountDao.queryAccountByUserId(userId);
        BigDecimal shareBalance = amount.multiply(BigDecimal.valueOf(0.7)).multiply(BigDecimal.valueOf(quantity));
        BigDecimal frozenIn = amount.multiply(BigDecimal.valueOf(0.3)).multiply(BigDecimal.valueOf(quantity));
        account.setShareBalance(account.getShareBalance().add(shareBalance));
        account.setFrozenIn(account.getFrozenIn().add(frozenIn));
        accountDao.update(account);
        AccountRecord ar = new AccountRecord();
        ar.setIntoUserId(userId);
        ar.setUpdateTime(new Date());
        ar.setType("10");
        ar.setAmount(frozenIn);
        ar.setNowAmount(account.getFrozenIn());
        ar.setSign("1");
        ar.setOrderNo(orderNo);
        ar.setInfo(agentCode + "购买成功! 您获得管理奖（冻结）" + frozenIn);
        accountRecordDao.save(ar);
        AccountRecord ar1 = new AccountRecord();
        ar1.setIntoUserId(userId);
        ar1.setUpdateTime(new Date());
        ar1.setType("10");
        ar1.setAmount(shareBalance);
        ar1.setNowAmount(account.getShareBalance());
        ar1.setSign("1");
        ar1.setOrderNo(orderNo);
        ar1.setInfo(agentCode + "购买成功! 您获得管理奖：" + shareBalance);
        accountRecordDao.save(ar1);
        if(account.getFrozenIn().doubleValue() >= 369){
            // 进入复消
            OrdersShareRepeat osr = new OrdersShareRepeat();
            osr.setUserId(account.getUserId());
            osr.setUpdateTime(new Date());
            osr.setStatus("0");
            ordersShareRepeatDao.save(osr);
        }
    }


}
